I've been using a code with seemingly no problem for a quite a while now, and today it stopped working and in a pretty weird way. I have several SAS files in a folder and I want to export each of them into a CSV file, while keeping only some columns and if some condition is satisfied. The file structure is folders called data_(year) and inside are several files called file_(region number) %macro extract_data(year);
libname lib "c:\data_&year.";
%let file_names = 24 27 29;
%let nb_files = 3;
%do i=1 %to &nb_files.;
%let next_file = %scan(&file_names, &i);
data file&next_file. (keep = C1 C2)
set lib.file_&next_file.;
if C1 = &next_file.;
run;
proc export data = file&next_file.
outfile = "c:\Export\file&year._&next_file."
dbms = csv
replace;
%end;
%mend;
%extract_data(2010) Today this stopped working and the error I get is for the FIRST file where I get an "ERROR 180-322: Statement is not valid or it is used out of proper order" underlining set. The really weird thing is that it does this only for the first file (ie in the example above 24) and then the other exports seem to go through. I tried with different triplets of file_names and now the one which didn't work before does (ie file_names = 12 24 27 and in this case 24 exported normally and it was 12 that didn't work). Thank you very much for your help!
... View more