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
Mention how to limit decimal places for the variable using proc means?
What are the new features included in the new version of SAS Programming Language?
what is hierarchy flattening? : Sas-di
List down the reasons for choosing sas over other data analytics tools.
Difference between informat and format?
What is SAS?
explain the function of substr in sas? : Sas-administrator
What are the different servers in sas? : sas-grid-administration
what is enterprise guide? What is the use of it? : Sas programming
Tell me more about the parameters in macro? : sas-macro
What are the implications?
What does proc print, and proc contents are used for?
What is auto call macro and how to create a auto call macro? What is the use of it? How to use it in sas with macros? : sas-macro
How would you code a macro statement to produce information on the sas log? This statement can be coded anywhere? : sas-macro
What is the purpose of trailing @ and @@? How do you use them?