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

Hi, can you please tell me what is wrong with my code? I get the following error when I run it: 

 

WARNING: Apparent symbolic reference J not resolved.
547 %put &j;
&j
548 %put &m;
WARNING: Apparent symbolic reference M not resolved.
&m
549 %put &r;
WARNING: Apparent symbolic reference R not resolved.
&r
550 %put &s;
WARNING: Apparent symbolic reference S not resolved.
&s

 

 

Here is my code: 

 

%LET alp=0.05;
%LET nn=30;
%LET side=twosided;


%macro calc(alp,nn,side);
%let side=%upcase(&side);
%if &side=TWOSIDED %then %do;
%let p1=%sysevalf(&alp/2);
%end;
%else %do; %let p1=&alp; %end;
%let p2=%sysevalf(1-&p1);
%let np1=%sysevalf(&nn*&p1);
%let np2=%sysevalf(&nn*&p2);
%LET m=%sysevalf(&np2,floor);
%if %sysevalf(&np1,floor)=0 %then %do;
%let j=1; %end;
%else %do;
%let j=%sysevalf((&np1,floor); %end;
%let r=%sysevalf(&np1+1,floor);
%let s=%sysevalf(&np2+1,floor);
data getit;
j=&j;
m=&m;
r=&r;
s=&s;
run;
%mend calc;
%calc(alp=&alp,nn=&nn,side=&side);
%put &j;
%put &m;
%put &r;
%put &s;

 

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Also, macro variables declared inside an array are local to the macro, they disappear when the macro ends. Create a global set of macro variables first and you shouldn't have that issue.

%global j m r s;

View solution in original post

3 REPLIES 3
Reeza
Super User
Without reading thoroughly or much, comparisons tend to be case sensitive, ie twosided IS NOT EQUAL to TWOSIDED
Reeza
Super User
Also, macro variables declared inside an array are local to the macro, they disappear when the macro ends. Create a global set of macro variables first and you shouldn't have that issue.

%global j m r s;
statz
Obsidian | Level 7

Thanks Reeza! I put the %global j m r s;

and it worked! 

 

Thanks a lot! 🙂

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 837 views
  • 1 like
  • 2 in conversation