Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mf_getkeyvalue.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief retrieves a key value pair from a control dataset
4 @details By default, control dataset is work.mp_setkeyvalue. Usage:
5
6 %mp_setkeyvalue(someindex,22,type=N)
7 %put %mf_getkeyvalue(someindex)
8
9
10 @param [in] key Provide a key on which to perform the lookup
11 @param [in] libds= (work.mp_setkeyvalue) The library.dataset which holds the
12 parameters
13
14 @version 9.2
15 @author Allan Bowe
16**/
17
18%macro mf_getkeyvalue(key,libds=work.mp_setkeyvalue
19)/*/STORE SOURCE*/;
20%local ds dsid key valc valn type rc;
21%let dsid=%sysfunc(open(&libds(where=(key="&key"))));
22%syscall set(dsid);
23%let rc = %sysfunc(fetch(&dsid));
24%let rc = %sysfunc(close(&dsid));
25
26%if &type=N %then %do;
27 &valn
28%end;
29%else %if &type=C %then %do;
30 &valc
31%end;
32%else %put %str(ERR)OR: Unable to find key &key in ds &libds;
33%mend mf_getkeyvalue;