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;


sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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