Hi, I have a question to insert a record to table 'sas_gbl_input_parm' within macro function. The table has 4 columns: parm_nm, value, location, description. %macro setrec (parm_nm, value, location, desc);
%if %length(&location)=0 %then %let location=_ALL_;
%let default_text=;
%let locid_text=;
proc sql noprint;
select parm_val into :default_text from sas_gbl_input_parm
where upcase(parm_nm)=upcase("&parm_nm")
and current_ind = 'Y'
;
quit;
proc sql noprint;
/* Insert a record to previous table no matter parm_nm exists */
%if &location ne _ALL_ and %length(&locid_text)=0
%then %do;
insert into sas_gbl_input_parm
set parm_nm = "&parm_nm"
, htl_cd = "&location"
, parm_val = "&value"
, current_ind = 'Y'
, lst_updt_usr_id = "User_1"
, lst_updt_ts = datetime()
;
%end; quit; %mend setrec; However, in this way, we will insert a record whether initial 'parm_nm' exists or not; How can I modify the code so that if the table already contains 'parm_nm' of the new record, it will just update the value of initial record; and if the table does not contain 'parm_nm' of the new record, it will insert a new row of 4 columns to prior table. Thanks!
... View more