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