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

Good morning,

I need some help rearranging data in a very large data set using SAS 9.4.

I have the data as follows (please see also attached Excel file) :

 

data k;

input  date  va  vb  vc  vd  ;

cards  ;

20000630    6.1207      8.7044      5.3283      5.846

20000929    6.1158      8.6934      5.3253      5.8423

20001229    5.7898      7.9828      5.1254      5.5832

20010330    4.9815      7.5266      4.4934      4.5082

;

run;

 

I would like to have the data  as:

va

20000630

6.1207

va

20000929

6.1158

va

20001229

5.7898

va

20010330

4.9815

vb

20000630

8.7044

vb

20000929

8.6934

vb

20001229

7.9828

vb

20010330

7.5266

vc

20000630

5.3283

vc

20000929

5.3253

vc

20001229

5.1254

vc

20010330

4.4934

vd

20000630

5.846

vd

20000929

5.8423

vd

20001229

5.5832

vd

20010330

4.5082

 

Thank you for your help,

Tomas

1 ACCEPTED SOLUTION

Accepted Solutions
TomKari
Onyx | Level 15

Thanks for posting the data step to make it easy!

proc transpose data=k out=ktrans;
	var va--vd;
	by date;
run;

proc sort;
	by _name_ date;
run;

View solution in original post

4 REPLIES 4
TomKari
Onyx | Level 15

Thanks for posting the data step to make it easy!

proc transpose data=k out=ktrans;
	var va--vd;
	by date;
run;

proc sort;
	by _name_ date;
run;
Thomas_mp
Obsidian | Level 7

Thank you Tom,

Regards,

Tomas

 

Ksharp
Super User
proc sql;
create table want as
select 'va' as label length=32,date,va as value from k
union all
select 'vb' as label length=32,date,vb as value from k
union all
.....................
quit;
Thomas_mp
Obsidian | Level 7

Thank you Diamond,

The Proc transpose works in this case.

One obstacle to implement your code is that I have 5000 variables Va, Vb,.... (etc),

But I appreciate you have taken time to help me,

Regards,

Tomas

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 851 views
  • 1 like
  • 3 in conversation