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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.