BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
CP2
Pyrite | Level 9 CP2
Pyrite | Level 9

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

3 REPLIES 3
Reeza
Super User

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;

CP2
Pyrite | Level 9 CP2
Pyrite | Level 9

too simple! Thank you!

ballardw
Super User

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.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1017 views
  • 2 likes
  • 3 in conversation