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


Please Help Members By Posting Answers For Below Questions

Give some examples where proc report’s defaults are different than proc print’s defaults?

603


What do you know about sas and what we do? : sas-grid-administration

608


what is the use of sas management console? : Sas-di

615


What versions of SAS have you used (on which platforms)?

1019


What does proc print, and proc contents are used for?

613






how to read the variables in sas? : Sas-administrator

556


what are the component of range? : Sas-bi

618


what is star schema? : Sas-di

649


why a stop statement is needed for the point= option on a set statement?

631


Explain append procedure?

636


If you use a symput in a data step, when and where can you use the macro variable? : sas-macro

613


If a variable contains only numbers, can it be a character data type?

616


What is the difference between the proc sql and data step?

667


Tell e how how dealt with..

1775


What are the difference between sas functions and procedures?

644