DATA Step, Macro, Functions and more

Change the structure of the presented data

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 12
Accepted Solution

Change the structure of the presented data

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


Accepted Solutions
Solution
‎09-27-2016 06:19 AM
Super User
Posts: 17,771

Re: Change the structure of the presented data


All Replies
Solution
‎09-27-2016 06:19 AM
Super User
Posts: 17,771

Re: Change the structure of the presented data

Proc Transpose Smiley Happy

Super User
Posts: 9,671

Re: Change the structure of the presented data


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;
Super User
Posts: 9,671

Re: Change the structure of the presented data

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;


☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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