MAGIC WITH CALL EXECUTE

by Irina 26. May 2007 11:16

Call execute- is a function that can be used if you want to run some code based on the values of a dataset.

Mixing DATA and PROC Steps.

You can't mix DATA and PROC steps. Each SAS step must complete before the next step begins.
For example, this program is illegal:
DATA _NULL_;
SET SALES END=NOMORE;
TOTAL + AMOUNT;
IF NOMORE;
IF TOTAL < 1000000 THEN DO;
PROC MEANS DATA=SALES;
CLASS STATE;
END;
ELSE DO;
PROC MEANS DATA=SALES;
CLASS STATE YEAR;
END;
However, CALL EXECUTE lets you designate the PROC and CLASS statements as statements to be added once the DATA step completes. This approach works, and requires minimal modification to the original:
DATA _NULL_;
SET SALES END=NOMORE;
TOTAL + AMOUNT;
IF NOMORE;
IF TOTAL < 1000000 THEN DO;
CALL EXECUTE
('PROC MEANS DATA=SALES;
CLASS STATE;');
END;
ELSE DO;
CALL EXECUTE
('PROC MEANS DATA=SALES;
CLASS STATE YEAR;');
END;
RUN;

sugi22

Related posts

Add comment


(will show your Gravatar icon)  





Live preview

7/30/2010 8:11:18 AM

 

About the author

Irina Spivak Irina Spivak
Team Leader at G-Stat. More...


Send mail Email

Authors

Blogroll

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010

    Sign in

    eXTReMe Tracker