Hello,
Is there a way to vertically append new data to an existing dataset but also bring over the new variables that don't exist in the base dataset? I thought 'force' would do it but it is not carrying over the new variables. Proc datasets with append doesn't do it either. What I want is a full join which includes all observations from both and all variables from both.
proc append base=dataprep3 data=AppendEMR force ;
run;
In SQL this is UNION ALL
data want;
set table1 table2:
run;
prox sql;
create table want2 as
select * from table1
union all
select * from table2;
quit;
In SQL this is UNION ALL
data want;
set table1 table2:
run;
prox sql;
create table want2 as
select * from table1
union all
select * from table2;
quit;
too simple! Thank you!
Note that if you have the same variable name but with different types you'll get an error.
If a same named variable has different lengths assigned you will get a warning message about possible truncation of data. Pay attention to these as you may actually lose critical data.
Also if other variable characteristics such as assigned label or format differs then you may want to verify that the desired one is in the results.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.