mirror of
https://github.com/sasjs/core.git
synced 2026-04-16 21:23:14 +00:00
feat(*): recreate library as scoped package
This commit is contained in:
52
base/mp_setkeyvalue.sas
Normal file
52
base/mp_setkeyvalue.sas
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
@file
|
||||
@brief Logs a key value pair a control dataset
|
||||
@details If the dataset does not exist, it is created. Usage:
|
||||
|
||||
%mp_setkeyvalue(someindex,22,type=N)
|
||||
%mp_setkeyvalue(somenewindex,somevalue)
|
||||
|
||||
<h4> Dependencies </h4>
|
||||
@li mf_existds.sas
|
||||
|
||||
@param key Provide a key on which to perform the lookup
|
||||
@param value Provide a value
|
||||
@param type= either C or N will populate valc and valn respectively. C is
|
||||
default.
|
||||
@param libds= define the target table to hold the parameters
|
||||
|
||||
@version 9.2
|
||||
@author Allan Bowe
|
||||
@source https://github.com/macropeople/macrocore
|
||||
|
||||
**/
|
||||
|
||||
%macro mp_setkeyvalue(key,value,type=C,libds=work.mp_setkeyvalue
|
||||
)/*/STORE SOURCE*/;
|
||||
|
||||
%if not (%mf_existds(&libds)) %then %do;
|
||||
data &libds (index=(key/unique));
|
||||
length key $32 valc $256 valn 8 type $1;
|
||||
call missing(of _all_);
|
||||
stop;
|
||||
run;
|
||||
%end;
|
||||
|
||||
proc sql;
|
||||
delete from &libds
|
||||
where key=symget('key');
|
||||
insert into &libds
|
||||
set key=symget('key')
|
||||
%if &type=C %then %do;
|
||||
,valc=symget('value')
|
||||
,type='C'
|
||||
%end;
|
||||
%else %do;
|
||||
,valn=symgetn('value')
|
||||
,type='N'
|
||||
%end;
|
||||
;
|
||||
|
||||
quit;
|
||||
|
||||
%mend;
|
||||
Reference in New Issue
Block a user