Hi guys, I am running a macro inside another macro but I am receiving an stranger error when executing. Although my program run and give me the database that I want, the error msg stops the program to keep running and it stops the onther programs that I have linked in my process flow and needs the firts one. So this is an example of what what I have: I receive some txt files every day with names that is something like this: "myFile_20211207_9825cd892ab73.txt" So, it means "myFile_YYYYMMDD_RANDOMCHARS.txt". Then I created a way to read the files in the directory, select only the files that I want, count them and then import those txts like this: /*Create a database with names of all files in the directory*/
data filenames;
length fref $8 fname $200;
did = filename(fref, '/sasdata/it_databases');
numero=dnum(did);
did = dopen(fref);
do i = 1 to dnum(did);
fname = dread(did,i);
extrac=substr(fname,29,17);
output;
end;
did = dclose(did);
did = filename(fref);
keep fname extrac;
run; Whit this I got the database filenames like the print below: Then I calculate the number of files that I have into the filenames directory and create a macro var num_obs with this number. /*Calculate the number os filesinside the directory (table filenames)*/
data _null_;
if 0 then
set work.filenames nobs=n;
call symputx('num_obs', n);
stop;
run; And after that I run the macro FILEE to import the txts into "IMPORT_OSA_&ORDER" databases. %MACRO FILEE(EXTENSION, ORDER);
DATA IMPORT_OSA_&ORDER.;
infile "/sasdata/it_databases/myFile_20211207_&EXTENSION...txt" dlm=';' dsd missover;
input
var1 : $CHAR3.
var2 : $CHAR2.
var3 : $CHAR5.
var4 : ?? BEST6.
;
run;
%MEND; And to finish my program, I running the code like below: data _null_;
set filenames;
call symputx(catx('_', 'intReg', _n_),_n_);
call symputx(catx('_', 'strName', _n_),extrac);
run;
%MACRO LOOP;
%local i;
%do i=1 %to &num_obs;
data _null_;
set filenames3;
if _n_=&i then
do;
%FILEE(&strName_&i., &i.);
END;
run;
%END;
%Mend LOOP;
%loop;
data import_osa;
set work.import_osa_:;
run; When I run the macro LOOP I got the database import_osa as I want, but it returnrs the errors below and it stop the executions of the linked programs in my project. WARNING: Apparent symbolic reference STRNAME_ not resolved.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
NOTE: Line generated by the invoked macro "ARQUIVO".
41 DATA IMPORT_OSA_&ORDER.; infile "/sasdata/it_databases/myFile_20211207_&EXTENSION...txt" dlm=';'
_
117
41 ! dsd missover; input var1 : $CHAR3. var2 : $CHAR2. var3 : $CHAR5.
ERROR 117-185: There was 1 unclosed DO block.
2 The SAS System 09:17 Tuesday, December 7, 2021
NOTE: The infile "/sasdata/it_databases/myFile_20211207_0847bdc1.txt" is:
Filename=/sasdata/it_databases/myFile_20211207_0847bdc1.txt,
Owner Name=belibio,Group Name=staff,
Access Permission=-rw-r--r--,
Last Modified=07Dec2021:01:36:36,
File Size (bytes)=432136340
NOTE: 346211 records were read from the infile "/sasdata/it_databases/myFile_20211207_0847bdc1.txt".
The minimum record length was 6.
The maximum record length was 16765.
NOTE: The data set WORK.IMPORT_OSA_1 has 346211 observations and 523 variables.
NOTE: Compressing data set WORK.IMPORT_OSA_1 decreased size by 96.13 percent.
Compressed is 2678 pages; un-compressed would require 69243 pages.
NOTE: DATA statement used (Total process time):
real time 2:08.40
cpu time 10.12 seconds
180: LINE and COLUMN cannot be determined.
NOTE: NOSPOOL is on. Rerunning with OPTION SPOOL might allow recovery of the LINE and COLUMN where the error has occurred.
ERROR 180-322: Statement is not valid or it is used out of proper order.
WARNING: Apparent symbolic reference STRNAME_ not resolved. Can anyone help me to solve the errors? Or just give me another way to do this imports so I can continue automatically run the other programs that is linked in the project?
... View more