SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irm_add_function_package.sas
1/*----------------------------------------------------------------------
2 * NAME: irm_add_function_package.sas
3 *
4 * PURPOSE: Adds data set specified to CMPLIB option, optionally verifies
5 * existence of function(s) within the data set.
6 *
7 * NOTES:
8 *
9 * MACRO OPTIONS:
10 * CMPLIB - Specify 2-level name of function package to be
11 * added to CMPLIB option.
12 * CHECK_FUNCTION - OPTIONAL: Verify existence of space delimited list
13 * of function(s) within function package data set.
14 *----------------------------------------------------------------------*/
15
16%macro irm_add_function_package(cmplib = ,
17 check_function = );
18
19 %local func_found
20 cmpliblist;
21 %let func_found = 0;
22
23 /*-------------------------------------------
24 * Check if function package data set exists
25 *-------------------------------------------*/
26 %if %rsk_dsexist(&cmplib) %then
27 %do;
28 /*------------------------------------------------------
29 * Optionally check through list of functions specified
30 * if they exists within the function package
31 *------------------------------------------------------ */
32 %if &check_function ne %then
33 %do i = 1 %to %sysfunc(countw(&check_function));
34 proc sql noprint;
35 select count(*) into :func_found
36 from &cmplib
37 where find(_key_,"%scan(&check_function,&i)",'i');
38 quit;
39 %if &func_found eq 0 %then
40 %do;
41 %put ERROR: The function %qupcase(%scan(&check_function,&i)) could not be found.;
42 %return;
43 %end;
44 %end;
45 /* ------------------------------------------------
46 * Add function package to cmplib if exists
47 * ------------------------------------------------ */
48 data _null_;
49 length cmplib $32767.;
50 cmplib = getoption('cmplib');
51 cmplib = tranwrd(cmplib,"&cmplib",'');
52 cmplib = catx(' ',"&cmplib",translate(cmplib,'','(','',')'));
53 call symputx('cmpliblist',cmplib,'l');
54 run;
55
56 options cmplib=(&cmpliblist);
57
58 %put NOTE: Adding function package to CMPLIB option.;
59 %put NOTE: CMPLIB = %sysfunc(getoption(cmplib));
60 %end;
61 /*-------------------------------------------------
62 * Print error if function package does not exists
63 *-------------------------------------------------*/
64 %else
65 %do;
66 %put ERROR: Could not locate the data set %qupcase(&cmplib).;
67 %return;
68 %end;
69%mend irm_add_function_package;