Sas Training Session Essay

1282 WordsMar 28, 20146 Pages
SAS Training Session 3 Advanced Topics Using SAS Sun Li Centre for Academic Computing lsun@smu.edu.sg Outline • Using arrays in SAS – Recoding variables, computing new variable, collapsing over variables – Identify patterns across variables using arrays – Reshaping data format btw long and wide using arrays • Introduction to SAS Macro language (7 steps to get started) – Macro variables & functions – Defining and calling Macro definition – Macro programs for iterative processing • Applied longitudinal studies – Survival analysis – Estimating multilevel models using SAS – Panel data analysis Using arrays in SAS • Using arrays in SAS – – – – – Recoding variables Computing new variables Collapsing over variables Identify patterns across variables using arrays Reshaping data format btw long and wide using arrays ARRAY array_name(n) variable_list; ; Note: SAS arrays always work with DO-END loop. Using arrays in SAS faminc; DATA faminc; faminc1input famid faminc1-faminc12 ; datalines; datalines; 1 3281 3413 3114 2500 2700 3500 3114 -999 3514 1282 2434 2818 2 4042 3084 3108 3150 -999 3100 1531 2914 3819 4124 4274 4471 3 6015 6123 6113 -999 6100 6200 6186 6132 -999 4231 6039 6215 ; **recoding variables; recode_missing; DATA recode_missing; faminc; set faminc; array inc[12] faminc1 - faminc12; * do i = 1 to 12; * inc[i]=inc[i if inc[i]=-999 then inc[i]=.; end; drop i; RUN; array inc(*) faminc:; faminc:; do i =1 to dim(inc); Using arrays in SAS **computing new variables; tax_array; DATA tax_array; recode_missing; set recode_missing; faminc1array inc(12) faminc1-faminc12; taxinc1array tax(12) taxinc1-taxinc12; do month = 1 to 12; tax[month] = inc[month]*0.1; end; RUN; * collapsing over variables; quarter_array; DATA quarter_array; faminc; set faminc; Afaminc(12) faminc1vars*/ array Afaminc(12) faminc1-faminc12; /*existing vars*/

More about Sas Training Session Essay

Open Document