Hi,
Well, there are quite a few things wrong with that code I am afraid. Some obvious points: - This is: SLEEP_&id - is not shown in your code, no dataset sleep_x - where x is the &i.?
- This is invalid: %mend GAscoring(&id)
Now what I was suggesting in my code before was that rather than loop in the macro, you use the orginal dataset to generate calls out to the macro:
%macro GAscoring (file=);
data data_import;
length ...l
infile "&dir.\&file." lrecl=32760 encoding="wlatin1" termstr=crlf dlm=',' missover firstobs=101 dsd;
...
run;
...
proc append data=sleepwindow out=sleep_&id.;
run;
%mend GAscoring;
data _null_;
set dirlist;
call execute(cats('%GAscoring (file="',filein,'");'));
run;
This would simplfy your macro code. However, it maybe simpler than that. Can you provide a couple of example test data files? In the below, I simulate your dir list. From that I create a call execute statement which creates a file reference to all the rows in that dataset which conform to the rules given in the where clause. I then have a datastep that reads all those datafiles from the fileref.
data dirlist;
length csvname $20;
input csvname $;
datalines;
abcdef.csv
rtyuio.csv
werty.csv
;
run;
data _null_;
length fn $2000;
set dirlist (where=(substr(csvname,1,3) in ("abc","wer"))) end=last;
retain fn;
fn=catx(" ",fn,quote(strip(csvname)));
if last then call execute('filename mydata ('||strip(fn)||');');
run;
data total_data;
length datetimestamp...;
label datetimestamp...;
format ...;
infile mydata lrecl=32760 encoding="wlatin1" termstr=crlf dlm=',' missover firstobs=101 dsd;
input ...;
run;
You will of course have to modify it to your files as I don't have that, this is just to demonstrate how to do this kind of process in stadard datastep.
... View more