BookmarkSubscribeRSS Feed
Alankar
Fluorite | Level 6
Here we have an SQL full join code in SAS :

proc sql;
create table test as select * from prod1 full join prod2 on (prod1.fund = prod2.fund);
quit;

how can i write the same code by using Merge Statement in SAS Data Step Programming?

data test;
merge prod1 (in = a)
prod1 (in = b);
by fund;
??????????
run;

Thanks in Advance.
- Alankar
1 REPLY 1
ChrisNZ
Tourmaline | Level 20
You don't need any additional statements, merge by does a full join by default.

merge by does however require that tables/views you merge be sorted or indexed by the merge keys before-hand, whereas sql can sort (or do other things) on the fly if needed.

One case where the results will be different between merge by and sql are if you have non-unique keys in both tables as merge by does not do cartesian products.

Another case is if you have identically named variables, as sql will keep the values from the first table, whereas merge by will overwrite them with the second table's values.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 1155 views
  • 0 likes
  • 2 in conversation