I have a SAS code like this:
%if &tp. = kdb %then %do;
%let sn = "&kdbsn.";
%end;
%if &tp. = bkb %then %do;
%let sn = &bkbsn.;
%end;
%if &tp. = edw %then %do;
%let sn = &edwsn.;
%end;
%if &tp. = odw %then %do;
%let sn = &odwsn.;
%end;
%if &tp. = adw %then %do;
%let sn = &adwsn.;
%end;
%put &sn;
I need to do this for many other cases and the pattern is always the same. Depending on the variable &tp.
I set the variable &sn.
to the same value as a variable with a name that has the first 3 characters equal to value of &tp.
and two additional characters sn
. Is there a function that would return the name of variable that I need so I don't need to have endless number of if
statements?