Function/Subroutine Declarations
[code:1xs57qfa]proc fcmp outlib= sasuser.MySubs.MathFncs;
subroutine inverse( in, inv );
outargs inv;
if in = 0 then inv = .;
else inv = 1/in;
endsub;
function day_date( indate, type $ );
if type = "DAYS" then wkday = weekday(indate);
if type = "YEARS" then wkday = weekday(indate*365);
return( wkday );
endsub;
run;[/code:1xs57qfa]
SAS Global Option CMPLIB
[code:1xs57qfa]cmplib = sasuser.funcs;
cmplib = (sasuser.funcs work.functions mycat.funcs);
cmplib = sasuser.func1 - sasuser.func10;[/code:1xs57qfa]
<!-- m --><a class="postlink" href="http://support.sas.com/documentation/onlinedoc/base/91/fcmp.pdf">http://support.sas.com/documentation/on ... 1/fcmp.pdf</a><!-- m -->
我的SAS是9.1.3版的,下面是程序运行的log
1 proc fcmp outlib=work.funcs.math;
2 function test() $ 12;
3 length x $ 25;
4 length z $ 30;
5 x = '1234';
6 if x = '1234' then
7 return(x);
NOTE: Character value converted to numeric at line 7 column 8.
8 else
9 return(z);
NOTE: Character value converted to numeric at line 9 column 8.
10 endsub;
11 run;
NOTE: Function test saved to catalog work.funcs.math.
NOTE: PROCEDURE FCMP used (Total process time):
real time 0.15 seconds
cpu time 0.09 seconds
12 options cmplib = work.funcs;
13 data _null_;
14 y = test();
----
68
ERROR 68-185: The function TEST is unknown, or cannot be accessed.
15 put y=;
16 vlen = vlength(y);
17 put vlen=;
18 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
那个PDF文档写的很清楚吧,DATA STEP里能调用吗?呵呵呵。所以传个log上来,一看就知道哪里错了。
[quote:c6b5xg52]The following SAS procedures allow the use of the functions and subroutines created
by FCMP:
• CALIS
• COMPILE
• DISTANCE
• GA
• GENMOD
• MODEL
• NLIN
• NLMIXED
• NLP
• PHREG
• RISK DIMENSIONS
• ROBUSTREG
• SIMILAR
• SYLK[/quote:c6b5xg52]