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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1250 views
  • 2 likes
  • 3 in conversation