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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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;

View solution in original post

5 REPLIES 5
Reeza
Super User

Use a LEFT JOIN

rakeshvvv
Quartz | Level 8

I am not sure about the syntax for LEFT JOIN...SO POSTED here...

LinusH
Tourmaline | Level 20

Have you tried Google, or support.sas.com?

Data never sleeps
Astounding
PROC Star

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.


Reeza
Super User

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;

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
  • 5 replies
  • 903 views
  • 0 likes
  • 4 in conversation