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 the order of application for output data set options, input data set options and SAS statements?
if a variable contain dates like "2015/01"---"2015/12" (yymm) ,How to add day to those dates,if them month is jan then 31 if the month is feb then 28 so on ...
why a stop statement is needed for the point= option on a set statement?
How can sas program be validated?
Can you suggest us materials for sdtm mapping?
what are some differences between proc summary and proc means? : Sas programming
Explain the purpose of retain statement.
What is the use of the %include statement?
How many data types are there in SAS?
Mention how to limit decimal places for the variable using proc means?
what are some problems you might encounter in processing missing values? In data steps? Arithmetic? Comparisons? Functions? Classifying data? : Sas programming
How to test the debugging in sas?
What do the SAS log messages "numeric values have been converted to character" mean?
How do you convert basic cube to transaction cube and transaction cube to basic cube?
how can you import .csv file in to sas? : Sas programming