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 will calendar procedure do?

808


What is SAS?

781


In proc transpose and data step with arrays which one you pick?

2765


how would you create a data set with 1 observation and 30 variables from a data set with 30 observations and 1 variable? : Sas programming

1067


what is business intelligence? : Sas-bi

780






Did you used proc test? when?

1781


describe about physical data integration? : Sas-di

747


What are the difference between ceil and floor functions in sas?

1011


Difference between sum function and using “+” operator?

817


How would you define the end of a macro? : sas-macro

821


What is slibref?

936


what is the difference between: x=a+b+c+d; and x=sum (of a, b, c ,d);? : Sas programming

808


what are all the reports you generated in your recent project?

1918


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

7065


Mention the difference between ceil and floor functions in sas?

880