Hello all , I am attempting to manually translate some SPSS syntax into Stata syntax. It is a fairly large dataset and I am stuck on a section which does not seem to translate well. I would be really interested (and grateful) to see how the Stata community may approach this. The SPSS syntax generates some new variables which adds up the number of qualifications a student achieves. The syntax also creates other variables that counts how many qualifications an individual has been awarded at different levels. I have been attempting to use egen, rowfirst, _n, _N, count, gen and bysort commands with little success on Stata 16. I have posted the syntax in SPSS below for anyone that is bi-lingual. I would really appreciate any advice given. Best Wishes, Matthew
Code:
AGGREGATE /OUTFILE='H:\Data\spss_data\aggr1.sav' /BREAK=attainment_year uniqueid new_qualifications /quallevel_first=FIRST(quallevel) /qualresult1_first=FIRST(qualresult1) / qualcode_first=FIRST(qualcode) /centre_first_1=FIRST(centre) /entrystage_first=FIRST(entrystage) / subject_group_1=FIRST(subject_group) /sqalevel_first = FIRST (sqalevel) /sqalevel_1_first = FIRST (sqalevel_1). EXECUTE.
Code:
AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK= attainment_year uniqueid /N_BREAK=N. Variable LABELS N_Break 'number of SGs and level 3-4-5 qualifications'. execute.
Code:
AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK= attainment_year uniqueid sqalevel_first /N_BREAK2=N. Variable LABELS N_Break2 'number qualifications pass at least some '. execute. compute number_level3=0. if sqalevel_first=3 number_level3=N_BREAK2. execute. compute number_level4=0. if sqalevel_first=4 number_level4=N_BREAK2. execute. compute number_level5=0. if sqalevel_first=5 number_level5=N_BREAK2. execute. AGGREGATE /OUTFILE=* MODE=ADDVARIABLES /BREAK=attainment_year uniqueid /number_level3_max=MAX(number_level3) /number_level5_max=MAX(number_level5) /number_level4_max=Max(number_level4).
Comment