90 likes | 171 Views
Explore interactive data manipulation techniques in SAS, including reading, writing, subsetting, creating variables, viewing data, applying functions, and generating new observations. Utilize SAS datasets interactively to enhance analytical capabilities.
E N D
SAS ‘interface’ editor, log, output menus/tabs“Solutions” tab (look it over to see what SAS can do)“Help” tab - for any of R, SAS, WinBUGS the internet has some very useful info but exercise a bit of caution when ‘unofficial’ help – www.sas.com, www.r-project.org, www.mrc-bsu.cam.ac.uk/bugs/, www.ats.ucla.edu/stat
Reading in Data Interactively (demonstration)SAS data sets with libnameslibname in 'C:\Documents and Settings\WHALEN\Desktop'access=readonly;options nofmterr;Look at log
Writing out Data Interactively (demonstration)Exporting SAS dataset in a portable format libname outto xport'C:\Documents and Settings\WHALEN\Desktop\neweff.xpt' ;proccopyin=work out=outto;select eff;run;Look at log
Data Steps Subsetting some variable and observationsdata a; set in.eff;keep subjid rxgp age status week slpchg sleep0;if itt=1 and week=99;run; Look at log
Data Steps Creating new variablesdata b; set in.eff;keep subjid rxgp age status slpchg sleep0 slpchg2 slpchg3;if itt=1 and week=99;if status='Completed'then slpchg2=slpchg; else slpchg2=0.1;slpchg3=slpchg*(status='Completed') + 0.1*(status ne 'Completed'); run;Look at log
Viewing and Checking Data View data interactively (demonstration)procprintdata=b; where slpchg2=0.1;run; procprintdata=b; where slpchg2 ne slpchg3;run;Look at log
Data Step Functions Similar functions as in R or othersdata c; set in.eff;keep subjid rxgp age status sleep0 logslp0 log10sp0 expslp0;where itt=1 and week=99;logslp0=log(sleep0);log10sp0=log10(sleep0); * longer names in later SAS ver.;expslp0=exp(sleep0);run;
Data Steps Creating new observationsdata d; set in.eff;keep subjid rxgp age status slpchg slpchg2 sleep0;if itt=1 and week=99thendo obnew=1to3; slpchg2=round(slpchg+ 0.5*normal(0),0.01);output;end;run;Look at log