I appreciate the response, Tom. While I've worked with SAS for more than 15 yrs and usually fairly resourceful with online solutions, I have done little with macros -- so please forgive me. This is stretching my knowledge! 🙂 My original intent was to rename a .sas7bdat file to include the participant ID (i.e., "wideformat.sas7bdat" to "wideformat_0001.sas7bdat"), and then concatenate together. I anticipated I would rename each .sas7bdat file when completing the transition from XML file to rectangular file, so that all files could be stored in a single folder, and when any necessary data cleaning is complete for each file (e.g., one site sent an incomplete file with poor images/incomplete data, but has another file locally with complete data that can be resent), they could be concatenated into a single locked file for analysis. But if I modify your code that uses the original XML files, I don't believe I am obtaining the file names with the participant ID inserted, but rather just retaining the ID (see output below; original XML file names (filenames) were C1000006 and C1000555). I'm still trying to determine how I can perhaps use your coding suggestions below for my needs described above, so appreciate any further insight you have. Obs filename id
1 C1000006.xml C1000006
2 C1000555.xml C1000555 Here is my code (minimal changes -- only to include my X:\ file directory): data filelist;
infile 'dir "X:\XML Data\SAS Trial XML files\*.xml" /b' pipe truncover ;
input filename $256.;
id = scan(filename,-2,'._');
run;
proc print; run;
%macro readonexml(filename=,id=,out=);
.....
%mend;
filename code temp;
data _null_;
set filelist ;
file code;
put '%readonexml(' filename= :$quote. ',' id= ',out=next)' ;
put 'proc append data=next base=all force; run;' ;
put 'proc delete data=next; run;';
run;
proc print; run; Thanks again.
... View more