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
How to limit decimal places for variable using proc means?
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
Differentiate between sas functions and sas procedures.
I am preparing SAS Certified Advanced Programmer for SAS 9 in 2014. If anybody has the latest dumps for this exam, please mail me at dhiman.mukherjee@gmail.com
What is proc sort?
How do you use the do loop if you don’t know how many times you should execute the do loop?
What is SAS?
how to generate the test data in sas without input data? : Sas-administrator
Are you involved in writing the inferential analysis plan? Tables specifications?
What are the applications primarily used by business analyst? : Sas-bi
What is factor analysis?
Differentiate between format and informat? : sas-grid-administration
Do you need to rearrange the order of the data for the report?
What are the parameters of scan function?
Enlist the functions performed by sas.