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

How to limit decimal places for variable using proc means?

579


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

686


Differentiate between sas functions and sas procedures.

630


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

2257


What is proc sort?

710






How do you use the do loop if you don’t know how many times you should execute the do loop?

740


What is SAS?

609


how to generate the test data in sas without input data? : Sas-administrator

564


Are you involved in writing the inferential analysis plan? Tables specifications?

3471


What are the applications primarily used by business analyst? : Sas-bi

543


What is factor analysis?

651


Differentiate between format and informat? : sas-grid-administration

569


Do you need to rearrange the order of the data for the report?

1825


What are the parameters of scan function?

607


Enlist the functions performed by sas.

666