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
Name and describe few sas character functions that are used for data cleaning in brief.
Name validation tools used in SAS
What does proc print, and proc contents are used for?
What is the difference between where and if statement?
Mention what is the difference between nodupkey and nodup options?
What was the last computer book you purchased? Why?
Given an unsorted data set, how to read the last observation to a new data set?
What is auto call macro and how to create a auto call macro? What is the use of it? How to use it in sas with macros? : sas-macro
Differentiate between proc means and proc summary.
Explain what is SAS informats?
How do you convert basic cube to transaction cube and transaction cube to basic cube?
explain the key concept of sas? : Sas-administrator
What is the function of output statement in a SAS Program?
why a stop statement is needed for the point= option on a set statement?
what can you learn from the sas log when debugging? : Sas programming