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

Hello, all

 

I am using a cox proportional hazard model and trying to add a time-dependent variable into the model, as suggested by http://ms.uky.edu/~mai/sta635/Cox%20model.pdf (p. 28). 

 

I keep facing the error message below: 

ERROR: Cannot find a library containing subroutine SYMPTOTAL_.

What seems to be the problem? I would greatly appreciate your help. 

 

proc phreg data = perm.habc_cox9; 
	class gender	site	race; 
	model time_event*censor(0)= gender	site	race	CV15Q1AGE	burden_td ; 
	array symptotal_(*) symptotal_1-symptotal_12; 
		  burden_td = symptotal_(time_event); 
run;

 

Thank you, 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

To access elements of a SAS array in the DATA step or supported procedures, you can use square brackets:

burden_td = symptotal_[time_event]; 

You are using rounded parentheses, which mean "make a function call," but SAS doesn't know what function you are trying to call. It looked in every 'library' of functions and didn't find it.

 

View solution in original post

8 REPLIES 8
Rick_SAS
SAS Super FREQ

To access elements of a SAS array in the DATA step or supported procedures, you can use square brackets:

burden_td = symptotal_[time_event]; 

You are using rounded parentheses, which mean "make a function call," but SAS doesn't know what function you are trying to call. It looked in every 'library' of functions and didn't find it.

 

Tom
Super User Tom
Super User

@Rick_SAS wrote:

To access elements of a SAS array in the DATA step or supported procedures, you can use square brackets:

burden_td = symptotal_[time_event]; 

You are using rounded parentheses, which mean "make a function call," but SAS doesn't know what function you are trying to call. It looked in every 'library' of functions and didn't find it.

 


SAS has used parenthesis for array indexing for decades.  

 73         data _null_;
 74           array symptotal_ (4) ;
 75           do time_event=1 to dim(symptotal_);
 76             burden_td + symptotal_(time_event);
 77           end;
 78         run;
 
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds

I suspect that the real problem is that you cannot use ARRAY and assignment statements in PROC step.

 

 

Reeza
Super User

@Tom PROC PHREG does support Programming Statements including array declarations. In the docs it does indicate the square brackets. I wonder if this is one of the few cases where it does matter...

 

 

Rick_SAS
SAS Super FREQ

Sorry that I was unclear. Tom is correct that IN THE DATA STEP it is legal (for historical reasons) to use rounded brackets for indices. But you should train yourself to use square brackets because those are the operators that are supported in both the DATA step and SAS procedures. Some people use curly braces for indexing, but those are not universally supported in all procedures (for example, SAS/IML only supports square brackets.)

 

Compare the following PROC PHREG steps and notice that the first gives the "Cannot find a library " error:

 

data Have;
array x(3) x1-x3;
do i = 1 to 3;
   x(i) = i;
end;
t = 1;
run;

proc phreg data=Have;
array x(3) x1-x3;
y = x(i);
run;

proc phreg data=Have;
array x(3) x1-x3;
y = x[i];
run;

Tom
Super User Tom
Super User

So how do we get SAS to fix the PHREG compiler so it supports normal SAS syntax?

 

I gave using goofy characters when I switched from using APL to using SAS thirty years ago.

Rick_SAS
SAS Super FREQ

This syntax is documented and has been around for many years, so I assume it is unlikely to change. The SAS/STAT documentation states that procedures and PROC FCMP use an "ARRAY statement [that] is similar to, but not the same as, the ARRAY statement in the DATA step." In particular, "You can index array elements by enclosing a subscript in braces ({ }) or brackets ([ ]), but not in parentheses (( )). The parentheses are reserved for function calls only."

 

There are other differences between the ARRAY statement in procedures and in the DATA step.The most comprehensive discussion of the difference is documented in the doc for PROC FCMP.

Tom
Super User Tom
Super User

Does this limitation mean that you can use an array name that conflicts with a SAS or user defined function name?  And reference both in the same PROC step?

 

That would be a benefit of forcing users to use strange characters in their code.

 

ejay0503
Obsidian | Level 7

Rick, I wanted to say your suggestion did solve the problem! No more error message and the Cox model did run correctly. I super really appreciate your help!!

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
  • 8 replies
  • 3470 views
  • 7 likes
  • 4 in conversation