BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MichaelSwift
Calcite | Level 5

 

The  following SAS9.3 code in macro:

 

  /* A few extreme values of could distort graphical output.
    Comparisons are made in succession from highest to next higher
    value for the top 5 extreme values. If the highest value is larger than
    twice the next higher value, then the highest value will be left out
    of the graph by assigning Rmax to the next higher value. Rmax  
    specifies the maximum value of the graphical axis line
    (xaxis or yaxis). */
 ods select ExtremeValues;
 Proc Univariate Data=&InDat NExtrVal=5;
 	Var &RType;
	ods output ExtremeValues = ExtremeValues;
 Run;
 options mprint mlogic symbolgen;
 Data _Null_;
   Set ExtremeValues;
   If _N_ = 1 Then Call Symputx('High5',High);
   If _N_ = 2 Then Call Symputx('High4',High); 
   If _N_ = 3 Then Call Symputx('High3',High); 
   If _N_ = 4 Then Call Symputx('High2',High); 
   If _N_ = 5 Then Call Symputx('High1',High);
 Run;
 %Do I = 1 %To 4;
   	%If %Sysevalf(&&High&I/&&High%Eval(&I+1)) > 1.3 %Then %Let RMax = %Sysevalf(&&High%Eval(&I+1),ceil);
 %End;
 options nomprint nomlogic nosymbolgen;

It produces the correct value of RMax but there are log warnings:

 

MPRINT(NEGBININF):   symbolgen;
MPRINT(NEGBININF):   Data _Null_;
MPRINT(NEGBININF):   Set ExtremeValues;
MPRINT(NEGBININF):   If _N_ = 1 Then Call Symputx('High5',High);
MPRINT(NEGBININF):   If _N_ = 2 Then Call Symputx('High4',High);
MPRINT(NEGBININF):   If _N_ = 3 Then Call Symputx('High3',High);
MPRINT(NEGBININF):   If _N_ = 4 Then Call Symputx('High2',High);
MPRINT(NEGBININF):   If _N_ = 5 Then Call Symputx('High1',High);
MPRINT(NEGBININF):   Run;

NOTE: There were 5 observations read from the data set WORK.EXTREMEVALUES.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


MLOGIC(NEGBININF):  %DO loop beginning; index variable I; start value is 1; stop value is 4; by
      value is 1.
SYMBOLGEN:  && resolves to &.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable HIGH1 resolves to 122.34597475
SYMBOLGEN:  && resolves to &.
WARNING: Apparent symbolic reference HIGH not resolved.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable HIGH2 resolves to 104.85413396
MLOGIC(NEGBININF):  %IF condition %Sysevalf(&&High&I/&&High%Eval(&I+1)) > 1.3 is FALSE
MLOGIC(NEGBININF):  %DO loop index variable I is now 2; loop will iterate again.
SYMBOLGEN:  && resolves to &.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable HIGH2 resolves to 104.85413396
SYMBOLGEN:  && resolves to &.
WARNING: Apparent symbolic reference HIGH not resolved.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable HIGH3 resolves to 77.716058462
MLOGIC(NEGBININF):  %IF condition %Sysevalf(&&High&I/&&High%Eval(&I+1)) > 1.3 is TRUE
MLOGIC(NEGBININF):  %LET (variable name is RMAX)
SYMBOLGEN:  && resolves to &.
WARNING: Apparent symbolic reference HIGH not resolved.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable HIGH3 resolves to 77.716058462
MLOGIC(NEGBININF):  %DO loop index variable I is now 3; loop will iterate again.
SYMBOLGEN:  && resolves to &.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable HIGH3 resolves to 77.716058462
SYMBOLGEN:  && resolves to &.
WARNING: Apparent symbolic reference HIGH not resolved.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable HIGH4 resolves to 75.249510073
MLOGIC(NEGBININF):  %IF condition %Sysevalf(&&High&I/&&High%Eval(&I+1)) > 1.3 is FALSE
MLOGIC(NEGBININF):  %DO loop index variable I is now 4; loop will iterate again.
SYMBOLGEN:  && resolves to &.
SYMBOLGEN:  Macro variable I resolves to 4
SYMBOLGEN:  Macro variable HIGH4 resolves to 75.249510073
SYMBOLGEN:  && resolves to &.
WARNING: Apparent symbolic reference HIGH not resolved.
SYMBOLGEN:  Macro variable I resolves to 4
SYMBOLGEN:  Macro variable HIGH5 resolves to 59.803347257
MLOGIC(NEGBININF):  %IF condition %Sysevalf(&&High&I/&&High%Eval(&I+1)) > 1.3 is FALSE
MLOGIC(NEGBININF):  %DO loop index variable I is now 5; loop will not iterate again.
MPRINT(NEGBININF):   options nomprint nomlogic
NOTE: Overwriting existing template/link: Sgdesign
NOTE: STATGRAPH 'Sgdesign' has been saved to: SASUSER.TEMPLAT
NOTE: PROCEDURE TEMPLATE used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

Appearing to provide a warning for the line

 

%If %Sysevalf(&&High&I/&&High%Eval(&I+1)) > 1.3 %Then %Let RMax = %Sysevalf(&&High%Eval(&I+1),ceil);
 

 Why?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
MichaelSwift
Calcite | Level 5

Thanks Paige Miller! Code now doesn't log Warning messages. Oink! Oink! 🙂

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

&&high&i works as intended

&&high%eval(&i+1) does not work because it is not in the format &&macrovar&index

 

perhaps you want this

%let oink=%eval(&i+1);

&&high&oink

--
Paige Miller
MichaelSwift
Calcite | Level 5

Thanks Paige Miller! Code now doesn't log Warning messages. Oink! Oink! 🙂

malkuchi
Calcite | Level 5

Could you please guide on below Error, I am comparing data and when matched setting a string to a variable

I need to send the result in an email, so I need value outside the code block.

 

SAS CODE:
DATA _NULL_;
if (10 EQ 10) then ValResult ="MATCHED" ; ValResult ="NOT MATCHED" ;
RUN;

%put &ValResult.;

 

 

LOG:

%put &ValResult.;
WARNING: Apparent symbolic reference VALRESULT not resolved.
&ValResult.

 

RESULT:

in results tab I am getting MATCHED

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2871 views
  • 0 likes
  • 3 in conversation