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

Hi guys,

 

My task is very simple. I'm using PROC LOGISTIC with the argument ctable and pprob.

If I use pprob=0.5 (a number) my procedure runs. However, whenever I try an expression (say 10/100 or, more interestingly, a variable's name inside an expression like i/100) SAS returns the following error:

 

ERROR 22-322: Syntax error, expecting one of the following: a numeric constant, a datetime constant, (.
 
I need to use this inside a macro and vary the values of pprobs from 0.01 to 1. I've attached code (in SAS Studio) and data. The part that does not run is the very last (the logistic_macro).
 
%macro logistic_macro; 
	%do i = 1 %to 100;
     	proc logistic data=WORK.GLMDesign outmodel=final_model noprint;
		class Col3 Col4 Col7 Col8 Col9 Col13 Col22 Col23 Col27 Col28 / param=glm;
		model VAR21(event='1')= Col3 Col4 Col7 Col8 Col9 Col13 Col22 Col23 Col27 Col28
			Col2  / link=logit technique=fisher ctable  pprob=%EVAL(&i./100) ;
		output out=preds predprobs=individual;
		score data=testset out=TestPred_new;
		run;
		proc freq data=TestPred_new;
    	table VAR21*I_VAR21 / out=CellCounts_new noprint;
		run;
		proc iml; /* using matrix language like in HW06 to make our lives easier */
		loss= j(100, 1, 0);  /*vector to store loss for different thresholds */
		use work.CellCounts_new; 
		read all var _ALL_ into M;
		close work.CellCounts_new;
		FalsePos = M[2,2] # 5; 
		FalseNeg = M[3,2]; 
		loss[i] = FalsePos + FalseNeg;
		print loss;
     %end; 
%mend;

%logistic_macro; *runs the macro;
I appreciate your help as usual!
1 ACCEPTED SOLUTION

Accepted Solutions
lrudolphi
Obsidian | Level 7

That's strange. I just tried it with dummy data and it worked for me, meaning changing the option to

pprob=%SYSEVALF(&i./100)

 

 

View solution in original post

6 REPLIES 6
lrudolphi
Obsidian | Level 7

%EVAL won't give you the decimal accuracy that you need. Try %SYSEVALF instead.

%let i=1;
%put %EVAL(&i./100);
%put %SYSEVALF(&i./100);

If you were to run the above, here are the results printed to the log:

0
0.01
 

marianaalcos
Quartz | Level 8
Hi lrudolphi,

Thanks for the comments, but I still got the same error. I had actually tried SYSEVALF before with put, but it seems that the argument pprob will not accept it =/
lrudolphi
Obsidian | Level 7

That's strange. I just tried it with dummy data and it worked for me, meaning changing the option to

pprob=%SYSEVALF(&i./100)

 

 

marianaalcos
Quartz | Level 8
Hi Irudolphi,

I actually went back to the log and the ERROR message has changed, now it is displaying the following message:
"Matrix has not been set to a value".
So I guess the SYSEVALF worked.
Any ideas what may be causing the new error? Thanks a lot!
lrudolphi
Obsidian | Level 7
Apologies, I am not too familiar with proc iml, so unfortunately cannot help solve that part. Glad the other part worked, though!
marianaalcos
Quartz | Level 8
That's okay, I guess I'll just post a new question, because I used proc iml outside the macro and it worked. Thanks anyways!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 2114 views
  • 2 likes
  • 2 in conversation