Can some one give me a proc sql code for the following query in sas
PROC SORT DATA=x OUT=x;
BY a;
RUN;
PROC SORT DATA=z OUT=z (KEEP = a b c);
BY a;
RUN;
DATA final;
MERGE x(IN=A) z;
BY a;
IF A;
RUN;
Assuming that the duplicate variable of A and in=A is an accident, see page 4 here:
http://support.sas.com/resources/papers/proceedings09/035-2009.pdf
There is some default behaviour that is not replicable between the data step/sql step such as how they treat the merge if the two data sets have the same variable.
proc sql;
create table want as
select a.*, b.*
from a
left join b
on a.var1=b.var1
order by var1;
quit;
Use a LEFT JOIN
I am not sure about the syntax for LEFT JOIN...SO POSTED here...
Have you tried Google, or support.sas.com?
This program is like making mud pies ... you might have fun experimenting with it, but you would never use it. There is no practical use for a program that uses a BY variable and an IN= variable having the same name.
Good luck.
Assuming that the duplicate variable of A and in=A is an accident, see page 4 here:
http://support.sas.com/resources/papers/proceedings09/035-2009.pdf
There is some default behaviour that is not replicable between the data step/sql step such as how they treat the merge if the two data sets have the same variable.
proc sql;
create table want as
select a.*, b.*
from a
left join b
on a.var1=b.var1
order by var1;
quit;
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.
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.