BookmarkSubscribeRSS Feed
mmea
Quartz | Level 8

Hi

I have this proc compare, where I compare two sets for differences:

proc compare 
 base = Set1
 compare = set2
	out= diff outdiff; 
run;

The out dataset diff - contains 4 variables: Type of observation = DIFF, observation number = 1, variable1 = 0, variable2 = 0.

 

I need a if statment that says: If variable1 and variable 2 = 0, in other words there is no difference, then do the next line of code.

 

I know the set up will be something like that, but how can I specify the two variables from DIFF?

 

%if  ??? and   ???  %then %do ; 

**put code here;

%end;
3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Try this

 

data want;
   set diff;
   if variable1 = 0 and variable2 = 0 then do;
      /* Your Statement Here */
   end;
run;
mmea
Quartz | Level 8

Does this work if my code is a proc sql? 🙂

mmea
Quartz | Level 8

also I have and else do after the do statment 🙂

 

So the statment should DO the proc sql code when variables = 0 else 

send out an email code

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 538 views
  • 1 like
  • 2 in conversation