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

Hi:

 

I have a do loop that calls a macro and runs a series of 13 data procedures before ending the loop.  Early on, at data step 7, I would know whether a series of variables within the dataset created in that step have certain values.  There is a single observation in the dataset.  To save time, I want to evaluate the variable's values and, if they fail to meet certain conditions, I want to end the macro and skip to the next iteration of the loop.  However, If the conditions are met, I want to finish the macro's remaining steps and go to the next iteration of the loop.  What is the best way to accomplish that?  Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

In a data step where you having this single observation, and you do the evaluation of whether or not the conditions are met, create a 0 or 1 variable named condition_met, then

 

call symputx('condition_met',condition met);

This creates a macro variable &CONDITION_MET, then in your macro

 

%if &condition_met %then %do;
     /* Remaining steps of the macro */
%end;
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

In a data step where you having this single observation, and you do the evaluation of whether or not the conditions are met, create a 0 or 1 variable named condition_met, then

 

call symputx('condition_met',condition met);

This creates a macro variable &CONDITION_MET, then in your macro

 

%if &condition_met %then %do;
     /* Remaining steps of the macro */
%end;
--
Paige Miller
mfp
Calcite | Level 5 mfp
Calcite | Level 5

Thanks for the fast reply.  I completely understand the second part.  Its creating the "condition met" as a 0 or 1 that is the stumbling block.

 

Here is the condition met logic for the variables:

 

if bluneconomic<0 and blironore>0 and blscrap>0 and blixrate<0 and blgfcf<0 and blalum<0 and bluneconomica<.05 and blironorea<.05 and blscrapa<.05 and blixratea<.05 and blgfcfa>.05 and blaluma<.05

PaigeMiller
Diamond | Level 26
call symputx('condition_met',bluneconomic<0 and blironore>0 and 
    blscrap>0 and blixrate<0 and blgfcf<0 and blalum<0 and
    bluneconomica<.05 and blironorea<.05 and blscrapa<.05 and 
    blixratea<.05 and blgfcfa>.05 and blaluma<.05);
--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 483 views
  • 1 like
  • 2 in conversation