data filelist;
infile 'dir "C:\Users\leejae\Desktop\xml testing\*.xml" /b' pipe truncover ;
input filename $256.;
filename=cats("&path",filename);
run;
%macro read_one(filename);
filename SXLELIB &filename ;
filename SXLEMAP 'C:\Users\leejae\Desktop\xml testing\map2.map';
libname SXLELIB xmlv2 xmlmap=SXLEMAP access=READONLY;
proc datasets lib=SXLELIB; run;
proc contents data=SXLELIB.SCAN varnum; run;
title 'Table SCAN';
proc print data=SXLELIB.SCAN; run;
title;
proc append base=all_SCAN data=sxlelib.SCAN force;
run;
%mend read_one;
filename code temp;
data _null_;
set filelist;
file code;
put '%read_one(' filename= :$quote. ');' ;
run;
%include code / source2; I am not understanding this. I never learned SAS formally, so I have a steep learning curve. I apologize. If I run the code with one file, I am able to out put the table and save the data. But when I run the macro, the shows that there are 0 observations, but it is reading all the files. 740 +%read_one(filename="&pathWong^Denise^^1039423^19600330^Female.xml" ); WARNING: Apparent symbolic reference PATHWONG not resolved. WARNING: Apparent symbolic reference PATHWONG not resolved. NOTE: Processing XMLMap version 2.1. NOTE: Libref SXLELIB was successfully assigned as follows: Engine: XMLV2 Physical Name: C:\Users\leejae\Desktop\xml testing\&pathWong^Denise^^1039423^19600330^Female.xml NOTE: PROCEDURE DATASETS used (Total process time): real time 0.00 seconds cpu time 0.01 seconds NOTE: PROCEDURE CONTENTS used (Total process time): real time 0.02 seconds cpu time 0.01 seconds NOTE: Access by observation number not available. Observation numbers will be counted by PROC PRINT. NOTE: No observations in data set SXLELIB.SCAN. NOTE: There were 0 observations read from the data set SXLELIB.SCAN. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds NOTE: Appending SXLELIB.SCAN to WORK.ALL_SCAN. NOTE: There were 0 observations read from the data set SXLELIB.SCAN. NOTE: 0 observations added. NOTE: The data set WORK.ALL_SCAN has 0 observations and 25 variables. NOTE: PROCEDURE APPEND used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 741 +%read_one(filename="&pathXMLExport.xml" ); WARNING: Apparent symbolic reference PATHXMLEXPORT not resolved. WARNING: Apparent symbolic reference PATHXMLEXPORT not resolved. NOTE: Processing XMLMap version 2.1. NOTE: Libref SXLELIB was successfully assigned as follows: Engine: XMLV2 Physical Name: C:\Users\leejae\Desktop\xml testing\&pathXMLExport.xml NOTE: PROCEDURE DATASETS used (Total process time): real time 0.00 sec I saw a different user post a code, but this one doesn't work for me either. I am confused and lost. *create macro to read all file names in folder*/
filename prueba pipe 'dir "C:\Users\leejae\Desktop\xml testing\*.xml" /b';
data file_list;
length fname $200;
infile prueba truncover; /* infile statement for file names */
input fname $200.; /* read the file names from the directory */
call symput ('num_files',_n_); /* store the record number in a macro variable */
run;
%macro fileread;
%do j=1 %to &num_files;
data _null_;
set file_list;
if _n_=&j;
call symput ('filein',fname);
run;
/*code to retrieve xml map created*/
filename SXLELIB 'C:\Users\leejae\Desktop\xml testing\&filein..xml';
filename SXLEMAP 'C:\Users\leejae\Desktop\xml testing\map2.map';
libname SXLELIB xmlv2 xmlmap=SXLEMAP access=READONLY ;
proc datasets lib=SXLELIB; run;
proc contents data=sxlelib._all_ varnum; run;
/*copy sxlelib to your library*/
proc copy in=sxlelib out=work;
run;
/*save each file read named 'alerta' as in xml mapper in a single sas dataset call data_all*/
%if &j=1 %then %do;
data data_all;
set SCAN;
run;
%end;
%else %do;
data data_all;
set data_all
SCAN;
run;
%end;
%end;
%mend fileread;
%fileread;
... View more