BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AdityaKir
Fluorite | Level 6

Hello,

 

I have a table structure like below

 

29/8/201331/8/20132/9/20134/9/2013
2114227424912660
151275570750
6777
1005112813261455

 

I want to change it to something like this

 

DatesSales
29/8/20132114
29/8/20132274
29/8/20132491
29/8/20132660
31/8/2013151
31/8/2013275
31/8/2013570
31/8/2013750

 

Can anybody help me to transpose it this way.

 

Regards,

 

Aditya

1 ACCEPTED SOLUTION

Accepted Solutions
3 REPLIES 3
Reeza
Super User

Proc Transpose 🙂

Ksharp
Super User

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;
Ksharp
Super User
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;


hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1538 views
  • 0 likes
  • 3 in conversation