Modify SAS dataset -


i have sas dataset looks this:

id | date | ...  1    17 jun  1    19 jun  2    17 jun  2    19 jun  2    21 jun  3    12 may 

each id represents unique person. want keep 1 row each unique person, however, still keep date in dataset. achieve this, need transform table format such as:

id | date1   |   date2 | date 3  1    17 jun      19 jun       2    17 jun     19 jun    21 jun    3    12 may         

if 1 date has been assigned person, keep date2 , date3 missing value.

the full dataset i'm using contains thousands of observations on 180 different days. however, unique person @ assigned 5 different days.

any appreciated

proc summary has functionality this, using idgroup statement. code below transpose data , create 5 date columns (specified out[5]), in date order (specified min(date)). if want more information on how works check idgroup statement in proc means / summary documentation.

data have; input id date :date9.; format date date9.;  datalines; 1 17jun2012 1 19jun2012 2 17jun2012 2 19jun2012 2 21jun2012 3 12may2012 ; run;  proc summary data=have nway; class id; output out=want (drop=_:)         idgroup(min(date) out[5] (date)=); run; 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -