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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.