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
Can you suggest us materials for sdtm mapping?
what is information maps?
for whom is sas data integration studio designed? : Sas-di
How would you code a merge that will write the matches of both to one data set, the non-matches from the left-most data?
describe how to adjust the performance of data integrator? : Sas-di
what is hash files in sas and why we are using this one in sas?
describe about metadata object? : Sas-di
How you are maintaining sas programmes in your company...any specific version control software you are using? If so, tell me the name?
What are the 3 components in sas programming?
where to use sas business intelligence? : Sas-bi
What is factor analysis?
Did you used proc test? when?
How to specify variables to be processed by the freq procedure?
If you have a dataset that contains 100 variables, but you need only five of those, what is the code to force SAS to use only those variables?
How to create list output for cross-tabulations in proc freq?