how we can call macros with in data step?

Answer Posted / pambrose

here is the answer with self explaining code... picked from SAS book

data prices; /* ID for price category and actual price */
input code amount;
datalines;
56 300
99 10000
24 225
;

data names; /* name of sales department and item sold */
input dept $ item $;
cards;
BB Boat
SK Ski
;
%macro items(codevar=); /* create macro variable if needed */
%global special;
data _null_;
set names;
if &codevar=99 and dept='BB' then
call symput('special', item);
run;
%mend items;

data _null_; /* call the macro in this step */
set prices;
if amount > 500 then
call execute('%items(codevar=' || code || ')' );
run;

data sales; /* use the value created by the macro in this step */
set prices;
length saleitem $ 20;
saleitem="&special";
run;

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is intially documentation in sas?

4335


How you are maintaining sas programmes in your company...any specific version control software you are using? If so, tell me the name?

1581


What are the best sas programming practices for handling very large datasets? : sas-grid-administration

569


what are 5 ways to perform a table lookup in sas? : Sas-administrator

765


which date functions advances a date time or date/time value by a given interval? : Sas programming

537






What is the difference between nodupkey and nodup options?

595


how many types of prompts are there? : Sas-bi

553


What do the SAS log messages "numeric values have been converted to character" mean?

890


for report generation which one you used proc report or data_null_?

6597


Explain the purpose of retain statement.

603


what are the scrubbing procedures in sas? : Sas programming

831


what is factor analysis? : Sas-administrator

613


Give some ways by which you can define the variables to produce the summary report (using proc report)?

599


how to do user inputs and command line arguments in sas?

2428


State the difference between INFORMAT and FORMAT ?

599