How to create unique ID's in SAS

sas

#1

ID Date Name
1 10/02/2013 A
1 12/02/2013 A
1 11/09/2012 A
1 '16/08/2012 A
2 10/04/2013 B
2 17/01/2014 B
2 18/09/2014 B
However I would like to display the data like:

What code should i write to do this??


#2
  1. Transposing one variable

Sometimes you need to reshape your data which is in a long format (shown below)
famid year faminc
1 96 40000
1 97 40500
1 98 41000
2 96 45000
2 97 45400
2 98 45800
3 96 75000
3 97 76000
3 98 77000
into a wide format (shown below).

famid faminc96 faminc97 faminc98
1 40000 40500 41000
2 45000 45400 45800
3 75000 76000 77000
Below is an example of using SAS proc transpose to reshape the data from a long to a wide format.

data long1 ;
input famid year faminc ;
cards ;
1 96 40000
1 97 40500
1 98 41000
2 96 45000
2 97 45400
2 98 45800
3 96 75000
3 97 76000
3 98 77000
;
run;

proc transpose data=long1 out=wide1 prefix=faminc;
by famid ;
id year;
var faminc;
run;

You can try this way ,this might help you. :smile:


#3

Sorry forgot to put the output above :

Obs famid NAME faminc96 faminc97 faminc98
1 1 faminc 40000 40500 41000
2 2 faminc 45000 45400 45800
3 3 faminc 75000 76000 77000