I am trying to do a couple do loops (or if there is anything more efficient I would like to hear) where I need to first go to the regional library. Each library can have multiple states. The code below works but when it goes through the regional folders, it goes through all 52 states and gives an error for the states that do not exist in that folder. Is there a more efficient/ cleaner log way where if the state is not in the regional folder, SAS skips it without an error message?
%syslput STATE1 = AK;
.
.
.
%syslput STATE52 = WY;
%let STATE1 = AK;
.
.
.
%let STATE52 = WY;
%syslput REGION1 = R1;
.
.
.
%syslput REGION8 = R9;
%macro onest;
%do r = 1 %to 8;
%syslput r = &R;
%do s = 1 %to 52;
%syslput s = &S;
rsubmit;
proc sql;
Connect to oracle
(path = xxxx user = &user pw = &pw);
create table &USER..&&STATE&S.._RX_HEADER as
select *
from connection to oracle
(
select distinct a.*
from M_&®ION&R.._OWN.&&STATE&S.._RX a
);
disconnect from oracle;
quit;
endrsubmit;
%end;
%end;
%mend onest;
%onest