Hello,
I have a table structure like below
29/8/2013 | 31/8/2013 | 2/9/2013 | 4/9/2013 |
2114 | 2274 | 2491 | 2660 |
151 | 275 | 570 | 750 |
6 | 7 | 7 | 7 |
1005 | 1128 | 1326 | 1455 |
I want to change it to something like this
Dates | Sales |
29/8/2013 | 2114 |
29/8/2013 | 2274 |
29/8/2013 | 2491 |
29/8/2013 | 2660 |
31/8/2013 | 151 |
31/8/2013 | 275 |
31/8/2013 | 570 |
31/8/2013 | 750 |
Can anybody help me to transpose it this way.
Regards,
Aditya
Proc Transpose 🙂
Proc Transpose 🙂
data have; infile cards expandtabs truncover; input _2982013 _3182013 _292013 _492013; cards; 2114 2274 2491 2660 151 275 570 750 6 7 7 7 1005 1128 1326 1455 ; run; proc transpose data=have(obs=0) out=temp; var _all_; run; data temp1; merge temp have; run; proc transpose data=temp1 out=want; by _name_ notsorted; run;
Or you want IML code ? data have; infile cards expandtabs truncover; input _2982013 _3182013 _292013 _492013; cards; 2114 2274 2491 2660 151 275 570 750 6 7 7 7 1005 1128 1326 1455 ; run; proc iml; use have; read all var _num_ into x[c=vnames]; close; n=j(1,ncol(x),ncol(x)); x1=t(repeat(vnames,n)); x2=colvec(x); create want var{x1 x2}; append; close; quit;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.