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
List out some key concept of SAS
What are the differences between proc means and proc summary?
What does proc print, and proc contents are used for?
what is data access? : Sas-di
which date functions advances a date time or date/time value by a given interval? : Sas programming
What is SAS informats?
What is SAS? What are the functions does it performs?
explain the difference between alternate key, business key, foreign key, generated key, primary key, retained key and surrogate key ? : Sas-di
Explain what Proc glm does?
What would be the result of the following SAS function (given that 31 Dec, 2000 is Sunday)?
To what type of programms have you used scratch macros?
What is run-group processing?
how the sas basic syntax style described? : Sas-administrator
what is intially documentation in sas?
How do you specify the number of iterations and specific condition within a single do loop?