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

Hi Folks:

I my data is stored by calendar years and I concatenated as shown in the code below. I'm curious if there was more efficient way to concatenate the datasets? I have more than 11 variables to read in actuality and I have to add variables onto all the lists every time I need I decide to add more variables into the analyses. 

data c.concatenated(COMPRESS=YES);
set c.data95(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
    c.data96(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data97(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data98(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data99(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data00(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data01(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data02(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data03(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data04(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data05(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data06(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data07(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data08(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data09(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data10(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data11(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data12(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
	c.data13(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11); 
run;  

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Or even

 

data c.concatenated(COMPRESS=YES);

set c.data95-c.data99(keep=var1-var11)
c.data00-c.data13(keep=var1 -var11); 
run;

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

HI @Cruise  Try this

UNTESTED

 


data c.concatenated(COMPRESS=YES);

set c.data95-c.data99(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11)
c.data00-c.data13(keep=var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11); 
run;
novinosrin
Tourmaline | Level 20

Or even

 

data c.concatenated(COMPRESS=YES);

set c.data95-c.data99(keep=var1-var11)
c.data00-c.data13(keep=var1 -var11); 
run;
Cruise
Ammonite | Level 13

@novinosrin 

Worked like a magic. Thanks much. 

data c.concatenated(compress=yes); 
set c.data1995-c.data2013 (keep=gender ethnic race age lensty zip dob source1-source6 ....); 
run; 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 658 views
  • 2 likes
  • 2 in conversation