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

Hi All,

 

I would really appreciate if someone could help me with the following.

I need to transpose below data 

 
GRP_aGRP_BGRP_CGRP_dGRP_ETotal_ValueTotal_Volume
abckeyColX aaGBP 39,775,2881634267
abckeyColX bbGBP 142,123,608722948
abckeyColX ccGBP 813,636,97922434774

 

 

to this format 

 

GRP_aGRP_BGRP_CGRP_daa_Valueaa_Volbb_Valuebb_Volumecc_Valuecc_Volume
abckeyColX GBP 39,775,2881634267###########722948########22434774
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

If you don't have a big table try double proc transpose.

 


data have;
infile cards expandtabs truncover;
input (GRP_a	GRP_B	GRP_C	GRP_d	GRP_E	Total_Value	Total_Volume ) (:$20.);
cards;
abc	key	ColX	. 	aa	GBP39,775,288	1634267
abc	key	ColX	. 	bb	GBP142,123,608	722948
abc	key	ColX	. 	cc	GBP813,636,979	22434774
;

proc transpose data=have out=temp;
by GRP_a	GRP_B	GRP_C	GRP_d GRP_E;
var Total_Value	Total_Volume;
run;
proc transpose data=temp out=want delimiter=_ ;
by GRP_a	GRP_B	GRP_C	GRP_d ;
var col1;
id GRP_E _name_;
run;

View solution in original post

1 REPLY 1
Ksharp
Super User

If you don't have a big table try double proc transpose.

 


data have;
infile cards expandtabs truncover;
input (GRP_a	GRP_B	GRP_C	GRP_d	GRP_E	Total_Value	Total_Volume ) (:$20.);
cards;
abc	key	ColX	. 	aa	GBP39,775,288	1634267
abc	key	ColX	. 	bb	GBP142,123,608	722948
abc	key	ColX	. 	cc	GBP813,636,979	22434774
;

proc transpose data=have out=temp;
by GRP_a	GRP_B	GRP_C	GRP_d GRP_E;
var Total_Value	Total_Volume;
run;
proc transpose data=temp out=want delimiter=_ ;
by GRP_a	GRP_B	GRP_C	GRP_d ;
var col1;
id GRP_E _name_;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 418 views
  • 1 like
  • 2 in conversation