LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sun, 10 May 2009 15:24:39 -0700
Reply-To:   "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Organization:   http://groups.google.com
Subject:   Re: Resolving macro variables inside % include .
Comments:   To: sas-l@uga.edu
Content-Type:   text/plain; charset=ISO-8859-1

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


Back to: Top of message | Previous page | Main SAS-L page