/ Published in: SAS
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* Create a SAS function called "LN" in FCMP and store it in a SAS catalog, where */ /* outlib=library.catalog.package specifies where the SAS function will be stored */ proc fcmp outlib = sasuser.FCMP_Cat.fcns; /* Example of a SAS function definition for the natural log */ function ln(x); y = log(x); return(y); endsub; quit; /* Let SAS know about the "FCMP_Cat" catalog */ options cmplib=(sasuser.FCMP_Cat); /* Test a call of the LN function using PROC FCMP */ proc fcmp; /* Example of calling SAS function "LN" */ out = ln(10); /* Print result to output listing */ put "Testing Function Call"; put "LN(10) returns:" out; quit; /* Generate synthetic data to be used in PROC MODEL */ data logdata; a = 0.5; do x=1 to 10000; z = rannor(123); y = log(a*x) + z; output; end; run; /* Utilize the "LN" function to estimate the parameter "a" with PROC MODEL */ proc model data = logdata; parameters a; y = ln(a*x); fit y; run; quit;
URL: http://support.sas.com/kb/26/151.html