Hi guys,
suppose to have a data set1 with column names and another data set2 with other column names. The two data sets have the same number of columns. Is there a way to allow data set2 to take column names of data set1 (position-wise)?
Thank you in advance
If TYPEs match on positions and LENGHTs agr "long enough" in set1, then the SQL union can do the job:
data set1;
A=1;
B="xyz";
C=42;
run;
data set2;
X=11;
Y="abc";
Z=421;
output;
X=12;
Y="abd";
Z=422;
output;
run;
proc sql;
create table WANT as
select * from set1(obs=0)
union all
select * from set2
;
quit;
proc print data=WANT;
run;
Bart
If TYPEs match on positions and LENGHTs agr "long enough" in set1, then the SQL union can do the job:
data set1;
A=1;
B="xyz";
C=42;
run;
data set2;
X=11;
Y="abc";
Z=421;
output;
X=12;
Y="abd";
Z=422;
output;
run;
proc sql;
create table WANT as
select * from set1(obs=0)
union all
select * from set2
;
quit;
proc print data=WANT;
run;
Bart
@NewUsrStat wrote:
Hi guys,
suppose to have a data set1 with column names and another data set2 with other column names. The two data sets have the same number of columns. Is there a way to allow data set2 to take column names of data set1 (position-wise)?
Thank you in advance
Can't you fix the creation of dataste2, so it uses the correct names instead of the wrong ones?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.