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

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.

 

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
  • 1010 views
  • 0 likes
  • 3 in conversation