BookmarkSubscribeRSS Feed
VinnyR
Calcite | Level 5

 

Edited...

 

How would I in a Proc SQL statement maintain this datastep: Also, I want to obtain a cartesian product so there is a deviation form datastep but it will be controlled by a where clause in the Proc SQl Code.

 

data want;

   merge dset_1 dset_2;

   by "some common variable properly sorted";

   if dset_1.var1 = dset_2.var1 then do;

     dset_1.var2=dset_2.var2;

     dset_1.var3=dset_2.var3;

  end;

  else do;

    dset_1.var1= "Missing";

    dset_1.var2= "Missing"; 

 end;   

run;

 

Somebody please help me understand this. I tried various combinations nothing worked.

 

Regards,

Vinny.

4 REPLIES 4
tomrvincent
Rhodochrosite | Level 12

I don't know what 'contelled' is, but what do you want to happen if dset_1.var1 is not equal to dset_2.var1?

VinnyR
Calcite | Level 5

Hi Tom,

 

I am sorry about that...updated the information.Thanks for noticing and notifying.

 

Regards,

Vinny.

tomrvincent
Rhodochrosite | Level 12

so you'd want to do a left join between the 2 tables.  Then your case statement can be something like

 

case when table2.var is missing then 'missing' else table2.var end

LinusH
Tourmaline | Level 20
You'll need a case for each var assignment, hence repeating of some logic - one little drawback for SQL over the data step.
Data never sleeps

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!

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