DATA Step, Macro, Functions and more

concatenating 10 data sets with same name variable with different lengths

Reply
New Contributor
Posts: 3

concatenating 10 data sets with same name variable with different lengths

hello.

 

i have ten datasets (z1-z10). they all have a variable named "group". the variable length varies in the ten datasets from 2 to 6.

 

is there a way i can concatenate all 10 datasets and have the "group" variable length be 6 in the final dataset without any data being truncated?

 

many thanks.

christine

Super User
Posts: 19,770

Re: concatenating 10 data sets with same name variable with different lengths

Posted in reply to christine1

What about this:

 

data want;
length group $10.;
set z1-z10;
run;
Super User
Posts: 10,020

Re: concatenating 10 data sets with same name variable with different lengths

Posted in reply to christine1
proc sql;
create table want as
 select * from z1
union all corr
 select * from z2
union all corr
............
 select * from z10
;
quit;
Ask a Question
Discussion stats
  • 2 replies
  • 159 views
  • 1 like
  • 3 in conversation