I have below macro in my SAS code. I have total of 2,000 customers that I run a report for. I have assigned them values from 1,000 to 3,000. When I run the code, at the end, it creates a table called ‘file_&i_allyrs’. I do not get data for same number of customers every time I run it. Sometimes, I get this table for only 1,000 customers and sometimes for 1,800 customers. The ‘i’ below is customer number assigned between 1000 and 3000.
%macro Read_ALL;
%do i = &beg %to &end;
data cont_&i;
set file_&i_allyrs;
cust = “&i”;
run;
/* appending rest of the file_&i._allyrs tables */
proc append base = all_files_allyears
data = cont_&i force;
run;
%end;
%mend ;
%macro byyr(beg, end);
%Read_ALL;
%mend;
%byyr(1000, 3000);
So, first it reads 'file_1000_allyrs' table. If this file does not exist, it gives an error and goes to read 'file_1001_allyrs' table..and so on.
Every time the file does not exist, it gives an error. Below is part of the error it gives.
ERROR: File FILES_1000_ALLYRS.DATA does not exist.
I would like the macro to skip the file it does not exist OR I would like to stop getting an error if the file does not exist.
How do accomplish that?
Thank you in advance