Programming the statistical procedures from SAS

ERROR: Cannot find a library containing subroutine...

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 17
Accepted Solution

ERROR: Cannot find a library containing subroutine...

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, 

 


Accepted Solutions
Solution
‎05-05-2018 01:36 PM
SAS Super FREQ
Posts: 4,243

Re: ERROR: Cannot find a library containing subroutine...

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


All Replies
Solution
‎05-05-2018 01:36 PM
SAS Super FREQ
Posts: 4,243

Re: ERROR: Cannot find a library containing subroutine...

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.

 

Super User
Super User
Posts: 8,120

Re: ERROR: Cannot find a library containing subroutine...

[ Edited ]

@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.

 

 

Super User
Posts: 23,771

Re: ERROR: Cannot find a library containing subroutine...

@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...

 

 

SAS Super FREQ
Posts: 4,243

Re: ERROR: Cannot find a library containing subroutine...

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;

Super User
Super User
Posts: 8,120

Re: ERROR: Cannot find a library containing subroutine...

[ Edited ]

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.

SAS Super FREQ
Posts: 4,243

Re: ERROR: Cannot find a library containing subroutine...

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.

Super User
Super User
Posts: 8,120

Re: ERROR: Cannot find a library containing subroutine...

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.

 

Occasional Contributor
Posts: 17

Re: ERROR: Cannot find a library containing subroutine...

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!!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 203 views
  • 6 likes
  • 4 in conversation