What is the option in Macro to display ERROR message if macro variable is not Resolved

  • Follow


Hi all,
The code is :

options sgen;
%let one = two;
%let two = three;
%let three = four;
%let four = last;
%put &&&&&last;

Output is :

357   %put &&&&&last;
SYMBOLGEN:  && resolves to &.
SYMBOLGEN:  && resolves to &.
SYMBOLGEN:  && resolves to &.
SYMBOLGEN:  && resolves to &.
WARNING: Apparent symbolic reference LAST not resolved.
&last

Now i want, if SAS doesn't find the Macro variable  "last" then
instead of WARNING:, it should display ERROR: message and it should
not print the output as "&last" .
Is there any way that sas will not output "&last' in the log ??
Please help.
Thanks in Advance.

Thanks and Regards,
Amar Mundankar.
0
Reply amarmundankar (89) 3/29/2010 4:40:57 AM

On Mar 29, 9:40=A0am, Amar Mundankar <amarmundan...@gmail.com> wrote:
> Hi all,
> The code is :
>
> options sgen;
> %let one =3D two;
> %let two =3D three;
> %let three =3D four;
> %let four =3D last;
> %put &&&&&last;
>
> Output is :
>
> 357 =A0 %put &&&&&last;
> SYMBOLGEN: =A0&& resolves to &.
> SYMBOLGEN: =A0&& resolves to &.
> SYMBOLGEN: =A0&& resolves to &.
> SYMBOLGEN: =A0&& resolves to &.
> WARNING: Apparent symbolic reference LAST not resolved.
> &last
>
> Now i want, if SAS doesn't find the Macro variable =A0"last" then
> instead of WARNING:, it should display ERROR: message and it should
> not print the output as "&last" .
> Is there any way that sas will not output "&last' in the log ??
> Please help.
> Thanks in Advance.
>
> Thanks and Regards,
> Amar Mundankar.

Hi all,
Does anybody have any idea about the above mentioned question?
Is it possible in SAS or not???
Please help.

Regards,
Amar Mundankar.
0
Reply Amar 4/1/2010 5:10:01 AM


You will need to test that yourself.
You can use the %SYMEXIST macro function to test if a macro variable
exists.
If you are inside a macro then use it in a %IF or other conditional
macro statement.
Otherwise try using %SYSFUNC with the IFC function.  For example look
at output of this code:

%let x=3Dxxx;
%put %sysfunc(IFC(%symexist(Y),%nrstr(&Y),NOT FOUND));
%put %sysfunc(IFC(%symexist(X),%nrstr(&X),NOT FOUND));


On Apr 1, 1:10=A0am, Amar Mundankar <amarmundan...@gmail.com> wrote:
> On Mar 29, 9:40=A0am, Amar Mundankar <amarmundan...@gmail.com> wrote:
>
>
>
>
>
> > Hi all,
> > The code is :
>
> > options sgen;
> > %let one =3D two;
> > %let two =3D three;
> > %let three =3D four;
> > %let four =3D last;
> > %put &&&&&last;
>
> > Output is :
>
> > 357 =A0 %put &&&&&last;
> > SYMBOLGEN: =A0&& resolves to &.
> > SYMBOLGEN: =A0&& resolves to &.
> > SYMBOLGEN: =A0&& resolves to &.
> > SYMBOLGEN: =A0&& resolves to &.
> > WARNING: Apparent symbolic reference LAST not resolved.
> > &last
>
> > Now i want, if SAS doesn't find the Macro variable =A0"last" then
> > instead of WARNING:, it should display ERROR: message and it should
> > not print the output as "&last" .
> > Is there any way that sas will not output "&last' in the log ??
> > Please help.
> > Thanks in Advance.
>
> > Thanks and Regards,
> > Amar Mundankar.
>
> Hi all,
> Does anybody have any idea about the above mentioned question?
> Is it possible in SAS or not???
> Please help.
>
> Regards,
> Amar Mundankar.- Hide quoted text -
>
> - Show quoted text -

0
Reply Tom 4/5/2010 8:45:32 PM

2 Replies
419 Views

(page loaded in 0.054 seconds)

Similiar Articles:













7/26/2012 12:21:12 PM


Reply: