Proc FCMP Example


/ Published in: SAS
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /* Create a SAS function called "LN" in FCMP and store it in a SAS catalog, where */
  2. /* outlib=library.catalog.package specifies where the SAS function will be stored */
  3. proc fcmp outlib = sasuser.FCMP_Cat.fcns;
  4. /* Example of a SAS function definition for the natural log */
  5. function ln(x);
  6. y = log(x);
  7. return(y);
  8. endsub;
  9. quit;
  10.  
  11.  
  12. /* Let SAS know about the "FCMP_Cat" catalog */
  13. options cmplib=(sasuser.FCMP_Cat);
  14.  
  15.  
  16. /* Test a call of the LN function using PROC FCMP */
  17. proc fcmp;
  18. /* Example of calling SAS function "LN" */
  19. out = ln(10);
  20. /* Print result to output listing */
  21. put "Testing Function Call";
  22. put "LN(10) returns:" out;
  23. quit;
  24.  
  25.  
  26. /* Generate synthetic data to be used in PROC MODEL */
  27. data logdata;
  28. a = 0.5;
  29. do x=1 to 10000;
  30. z = rannor(123);
  31. y = log(a*x) + z;
  32. output;
  33. end;
  34. run;
  35.  
  36.  
  37. /* Utilize the "LN" function to estimate the parameter "a" with PROC MODEL */
  38. proc model data = logdata;
  39. parameters a;
  40. y = ln(a*x);
  41. fit y;
  42. run;
  43. quit;

URL: http://support.sas.com/kb/26/151.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.