Good morning,
I need some help rearranging data in a very large data set using SAS 9.4.
I have the data as follows (please see also attached Excel file) :
data k;
input date va vb vc vd ;
cards ;
20000630 6.1207 8.7044 5.3283 5.846
20000929 6.1158 8.6934 5.3253 5.8423
20001229 5.7898 7.9828 5.1254 5.5832
20010330 4.9815 7.5266 4.4934 4.5082
;
run;
I would like to have the data as:
va | 20000630 | 6.1207 |
va | 20000929 | 6.1158 |
va | 20001229 | 5.7898 |
va | 20010330 | 4.9815 |
vb | 20000630 | 8.7044 |
vb | 20000929 | 8.6934 |
vb | 20001229 | 7.9828 |
vb | 20010330 | 7.5266 |
vc | 20000630 | 5.3283 |
vc | 20000929 | 5.3253 |
vc | 20001229 | 5.1254 |
vc | 20010330 | 4.4934 |
vd | 20000630 | 5.846 |
vd | 20000929 | 5.8423 |
vd | 20001229 | 5.5832 |
vd | 20010330 | 4.5082 |
Thank you for your help,
Tomas
Thanks for posting the data step to make it easy!
proc transpose data=k out=ktrans;
var va--vd;
by date;
run;
proc sort;
by _name_ date;
run;
Thanks for posting the data step to make it easy!
proc transpose data=k out=ktrans;
var va--vd;
by date;
run;
proc sort;
by _name_ date;
run;
Thank you Tom,
Regards,
Tomas
proc sql; create table want as select 'va' as label length=32,date,va as value from k union all select 'vb' as label length=32,date,vb as value from k union all ..................... quit;
Thank you Diamond,
The Proc transpose works in this case.
One obstacle to implement your code is that I have 5000 variables Va, Vb,.... (etc),
But I appreciate you have taken time to help me,
Regards,
Tomas
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.