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 execute macro within another macro? If so, how would sas know where the current macro ended and the new one began? : sas-macro
What is Linear Regression?
what are the types of interactive display types? : Sas-bi
Hi all, If Anybody has Advance SAS Certification dumps??? Please share with me. Email: pramod.kalugade03@gmail.com
what are the best practices to process the large data sets in sas programming? : Sas-administrator
what is information maps?
What does proc print, and proc contents are used for?
what is the Population you used in your project, is it ITT or PP?
how does sas handle missing values in a merge? : Sas programming
what has been your most common programming mistake? : Sas programming
In sas admin differentiate between roles and capabilities? : sas-grid-administration
What makes sas stand out to be the best over other data analytics tools?
Define run-group processing?
How long can a macro variable be? A token? : sas-macro
Tell e how how dealt with..