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

Hi All,

 

I need to make a combined list of all the columns. I can make a list based on each individual column using Proc SQL.

Is there a way I can make one long list of all the columns called Combined (Group1 Group2 etc) 

 

Proc SQL;
	Select QUOTE(TRIM(Group1)) INTO :Group1List
		Separated by " "
		From Test;
Quit;

 

Do I need to create a new column first and then use Proc SQL to create the list? Is there a simpler way of getting to what I need?

 

Data test;
	Input Group1 $ Group2 $ Group3 $ Group4 $ Group5 $;
		Datalines;
AA BA CA DA EA
AB BB CB DB EB
AC BC CC DC EC
AD BD CD DD ED
AE BE CE DE EE
AF BF CF DF  EF
AG BG CG DG EG
AH BH CH DH EH
AI BI CI DI EI
AJ BJ CJ DJ EJ
;
RUN;

 

 

Which gives me

Group1Group2Group3Group4Group5
AABACADAEA
ABBBCBDBEB
ACBCCCDCEC
ADBDCDDDED
AEBECEDEEE
AFBFCFDFEF
AGBGCGDGEG
AHBHCHDHEH
AIBICIDIEI
AJBJCJDJEJ

 

The output I need is:

 

Group1Group2Group3Group4Group5Combined
AABACADAEAAA
ABBBCBDBEBAB
ACBCCCDCECAC
ADBDCDDDEDAD
AEBECEDEEEAE
AFBFCFDFEFAF
AGBGCGDGEGAG
AHBHCHDHEHAH
AIBICIDIEIAI
AJBJCJDJEJAJ
     BA
     BB
     BC
     BD
     BE
     BF
     BG
     BH
     BI
     BJ
     CA
     CB
     CC
     CD
     CE
     CF
     CG
     CH
     CI
     CJ
     DA
     DB
     DC
     DD
     DE
     DF
     DG
     DH
     DI
     DJ
     EA
     EB
     EC
     ED
     EE
     EF
     EG
     EH
     EI
     EJ

 

 

Thanks in advance

 

Dean

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
Data test;
	Input Group1 $ Group2 $ Group3 $ Group4 $ Group5 $;
		Datalines;
AA BA CA DA EA
AB BB CB DB EB
AC BC CC DC EC
AD BD CD DD ED
AE BE CE DE EE
AF BF CF DF  EF
AG BG CG DG EG
AH BH CH DH EH
AI BI CI DI EI
AJ BJ CJ DJ EJ
;
RUN;

proc transpose data=test out=waw;
var group:;
run;

proc transpose data=waw out=waw1;
by _name_;
var col:;
run;

data final_want;
merge test waw1(keep=col1);
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20
Data test;
	Input Group1 $ Group2 $ Group3 $ Group4 $ Group5 $;
		Datalines;
AA BA CA DA EA
AB BB CB DB EB
AC BC CC DC EC
AD BD CD DD ED
AE BE CE DE EE
AF BF CF DF  EF
AG BG CG DG EG
AH BH CH DH EH
AI BI CI DI EI
AJ BJ CJ DJ EJ
;
RUN;

proc transpose data=test out=waw;
var group:;
run;

proc transpose data=waw out=waw1;
by _name_;
var col:;
run;

data final_want;
merge test waw1(keep=col1);
run;
Astounding
PROC Star

Untested, but ought to work:

 

proc sql;

select catx(' ', quote(trim(group1)), quote(trim(group2)), quote(trim(group3)), quote(trim(group4)), quote(trim(group5)))

into : grouplist separated by ' ' from test;

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 1705 views
  • 3 likes
  • 3 in conversation