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?
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.