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

I have a basic question:

data test; set temp1 temp2;run;

Temp1 and temp2 are 2 datasets with similar columns. Can somebody explain what this command is doing. Is it a union of the two datasets. Is there a better proc sql alternative to combine temp1 and temp2. 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

This is like a union all in sql. But compare your data step code with the necessary sql code:

proc sql;
create table test as
select * from temp1
union all
select * from temp2;
quit;

and you'll see why it's rarely used when the data step is much more concise. Aside from the fact that the data step has capabilities beyond those of sql.

View solution in original post

2 REPLIES 2
LinusH
Tourmaline | Level 20
Yes it is like a union.
Better depends in your requirements/preferences, but doing it in SQL would get you similar results.
Data never sleeps
Kurt_Bremser
Super User

This is like a union all in sql. But compare your data step code with the necessary sql code:

proc sql;
create table test as
select * from temp1
union all
select * from temp2;
quit;

and you'll see why it's rarely used when the data step is much more concise. Aside from the fact that the data step has capabilities beyond those of sql.

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