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 is intially documentation in sas?
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 best sas programming practices for handling very large datasets? : sas-grid-administration
what are 5 ways to perform a table lookup in sas? : Sas-administrator
which date functions advances a date time or date/time value by a given interval? : Sas programming
What is the difference between nodupkey and nodup options?
how many types of prompts are there? : Sas-bi
What do the SAS log messages "numeric values have been converted to character" mean?
for report generation which one you used proc report or data_null_?
Explain the purpose of retain statement.
what are the scrubbing procedures in sas? : Sas programming
what is factor analysis? : Sas-administrator
Give some ways by which you can define the variables to produce the summary report (using proc report)?
how to do user inputs and command line arguments in sas?
State the difference between INFORMAT and FORMAT ?