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
Give some examples where proc report’s defaults are different than proc print’s defaults?
What do you know about sas and what we do? : sas-grid-administration
what is the use of sas management console? : Sas-di
What versions of SAS have you used (on which platforms)?
What does proc print, and proc contents are used for?
how to read the variables in sas? : Sas-administrator
what are the component of range? : Sas-bi
what is star schema? : Sas-di
why a stop statement is needed for the point= option on a set statement?
Explain append procedure?
If you use a symput in a data step, when and where can you use the macro variable? : sas-macro
If a variable contains only numbers, can it be a character data type?
What is the difference between the proc sql and data step?
Tell e how how dealt with..
What are the difference between sas functions and procedures?