Date: Thu, 17 Nov 2011 15:32:41 -0500
Reply-To: Fatos US <fatosus@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Fatos US <fatosus@GMAIL.COM>
Subject: Re: macro statement question %let quest="...";
In-Reply-To: <0F548D585A011E4484D77C7B095EC53F0B24C8F4@TAC-CMS001.prod.ds.russell.com>
Content-Type: text/plain; charset=windows-1252
Mark:
I appreciate your time and help. I work now.
Fay
On Wed, Nov 16, 2011 at 1:47 PM, Terjeson, Mark <Mterjeson@russell.com>wrote:
> Hi Fay,
>
> Ahh, I see. Try this change.
>
> It is easier to synchronize quotation marks
> by not puttin them into your macro variables
> if you can avoid it. For most operations you
> will meet most all circumstances of syntax if
> you put the quote marks in where the code is
> that is being executed, for example:
>
> if you have your original:
>
> %let quest="ABC";
>
> and in your macro code you have some datastep
> code for example such as
> if mystring eq &quest then ....
> since macro resolution is the same as
> text-substitution you would get
> if mystring eq "ABC" then ....
> however, if you have
> %let quest=;
> the text-substitution would yield
> if mystring eq then ....
> and you would have a syntax error.
>
> So not putting quotes in the macro variable
> but at the logic location it then works for
> a value OR an empty or missing value.
> if mystring eq "&quest" then ....
> this will yield:
>
> for %let quest=ABC;
> if mystring eq "ABC" then ....
>
> for %let quest=;
> if mystring eq "" then ....
>
> now both are happy!
>
> See if that helps,
> Mark
>
>
>
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Fatos US
> Sent: Wednesday, November 16, 2011 7:47 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: macro statement question %let quest="...";
>
> Hi Mark:
>
> Thank you so much for your quick and detailed reply. But...
>
> I did try the *%let quest=; *
>
> but it yields *"*
>
> I also tried *%global quest;*
>
> it yields *"
> *
>
>
> *
> *
>
>
>
>
>
> On Wed, Nov 16, 2011 at 10:39 AM, Terjeson, Mark <Mterjeson@russell.com
> >wrote:
>
> > Hi Fay,
> >
> > Your comment that the result shows &quest
> > does not quite fit your suggested code repair
> > of %let quest=;
> >
> > When you see &quest as the resolved display
> > for the macro variable it means that the quest
> > macro variable has not been declared/allocated.
> > When it is declared/defined with either
> > %let quest=;
> > or %global quest;
> > Both will yield an empty output and avoid the &quest.
> >
> > So either you didn't have the %let quest=; at the
> > time of your test execution or some other timing issue
> > is coming into play. If your 4 lines of code are inside
> > another macro then a "scope" issue could come into play.
> > i.e. if a macro variable is needed from one macro into
> > another or after the macro you would need to predeclare
> > the macro variable with %global so that the default
> > instance of the macro variable only being local to the
> > macro is made available for later use outside the scope
> > of that macro.
> >
> > Long-story-short, if you actually pre-create your quest
> > macro variable with %global quest; or %let quest=;
> > then you should just yield an empty output instead of
> > the &quest display.
> >
> >
> >
> >
> >
> > Hope this is helpful.
> >
> >
> > Mark Terjeson
> > Investment Business Intelligence
> > Investment Management & Research
> > Russell Investments
> > 206-505-2367
> >
> >
> > Russell
> > Global Leaders in Multi-Manager Investing
> >
> >
> >
> >
> >
> >
> >
> > -----Original Message-----
> > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> > Fatos US
> > Sent: Wednesday, November 16, 2011 7:01 AM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: macro statement question %let quest="...";
> >
> > Hi everybody:
> > I am trying to produce web tables using the codes below
> >
> > %let topiclbl=XYZ;
> > %let quest="ABC";
> > %let level=2; %process (klm, &level, fmt.);
> > run;
> >
> > The result is fine. It looks good with topic being XYZ and question being
> > ABC
> >
> > but...
> > I don't need the question line. If my codes are as shown below, then the
> > topic is still XYZ which is what I want. But I don't need the quest.
> That's
> > why I remove the %let quest="ABC" but the output shows &quest
> >
> > %let topiclbl=XYZ;
> > %let quest= ;
> > %let level=2; %process (klm, &level, fmt.);
> > run;
> >
> >
> > How can I fix this problem? I do not need the quest line. Any help will
> be
> > appreciated.
> > Thank you,
> > Fay
> >
>
>
>
> --
> \\ - - //
> ( @ @ )
> +------oOOo-(_)-oOOo----------+---------------------------------+
>
> Amor Fati : "Love Your Fate", which is in fact your life. ~ Friedrich
> Nietzsche
>
--
\\ - - //
( @ @ )
+------oOOo-(_)-oOOo----------+---------------------------------+
Amor Fati : “Love Your Fate”, which is in fact your life. ~ Friedrich
Nietzsche
|