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
What will calendar procedure do?
What is SAS?
In proc transpose and data step with arrays which one you pick?
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
what is business intelligence? : Sas-bi
Did you used proc test? when?
describe about physical data integration? : Sas-di
What are the difference between ceil and floor functions in sas?
Difference between sum function and using “+” operator?
How would you define the end of a macro? : sas-macro
What is slibref?
what is the difference between: x=a+b+c+d; and x=sum (of a, b, c ,d);? : Sas programming
what are all the reports you generated in your recent project?
for report generation which one you used proc report or data_null_?
Mention the difference between ceil and floor functions in sas?