* Creating dicotomous variables. * This works if there is no missing data. compute hsplus = (educ >=12). execute. * Use this if there might be missing data. if (~missing(educ)) hsplus2 = (educ >=12). execute. * "recode" is usually used with categorical input, but can also handle data ranges. recode educ (8 thru 11 = 1 ) (12 thru highest = 2) into hsplus3. * more typical use of recode. recode jobcat (1 2 = 1) (3 4 = 2) into jobs2. execute. * Number cases within a group, here "gender" is a grouping variable. sort cases by gender bdate. compute seqnum = 1. if (gender = lag(gender)) seqnum = lag(seqnum) + 1. execute. * Does not require the data to be sorted. * However, the by variable must be numeric, and it does not handle ties. *sort cases by jobcat bdate. rank variables=bdate by jobcat /rank into jobid. sort cases by educ. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=educ /N_educ=N. sort cases by n_educ.