|
On May 9, 6:57 am, kedar....@GMAIL.COM (kedar B Shankar) wrote:
> HI All
>
> i am facing some problem , resolving macro varaiable inside the %include
> file.
>
> %include file will be generic one and i will pass the variables to it .
>
> so if any body can suggest an alternate to pass the macor variables into %
> include file . that would be of help
>
> the code i am trying is
>
> OPTION MLOGIC MPRINT source2 SYMBOLGEN;
>
> %macro test(n1=,a1=,g1=);
> %put " Inside test macro " &n1;
> %include "/home/nata.txt";
> %mend;
>
> data a;
> input name $ age gender $ ;
> cards;
> Tim 27 M
> Tom 28 F
> ;
> run;
>
> data _null_;
> set work.a;
> call symput('m_name',compress(name));
> call symput('m_age',compress(age));
> call symput('m_gender',compress(gender));
>
> call execute('%test(n1=&m_name,a1=&m_age,g1=&m_gender)');
> run;
Why are you using such convoluted execution scopes?
- SYMPUT followed by resolution in a CALL EXECUTE
There is no need to much around with macro variables, you already have
the values you need in the scope of the running DATA Step!
Also, it is highly recommended to wrap call execute content in a
%NRSTR so that the macro invocation is held off until the DATA Step
has completed running.
data _null_;
set a;
call execute ('%NRSTR('
|| '%test(n1=' || name
|| ',a1=' || age
|| ',g1=' || gender
|| ')'
);
run;
--
Richard A. DeVenezia
http://www.devenezia.com
|