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 do the sas log messages "numeric values have been converted to character" mean? : Sas programming
What is maximum number of rows and cols can be handled in SAS?
Explain the use of proc gplot? : sas-grid-administration
What is a method to debug and test your SAS program?
How might you use MOD and INT on numeric to mimic SUBSTR on character Strings?
If a variable contains only numbers, can it be a character data type?
What is the length assigned to the target variable by the scan function?
How would you invoke a macro? : sas-macro
what is scheduling and how will u implement it. In scheduling 5 jobs r running if there is an error occured at 3rd job and how will u check and waht necessary steps will u take not to repeat the same mistake
What is the good sas programming practices for processing large data sets?
In sas, what are the areas that you are most interested in? : sas-grid-administration
What is the difference between the proc sql and data step?
What is the difference between %put and symbolgen? : sas-macro
What is the difference between where and if statement?
what is SAS OPTIMIZATION?