Hi djbateman, see my solution... /* allocating output directories */ libname sasfile 'J:\SDTM\c_DefineXML\Define-XML-2-0_RP20140424\sdtm\sas_output'; /* create filename 'xptprgs' to capture all *.xpt files */ filename xptprgs pipe "dir /b J:\SDTM\c_DefineXML\Define-XML-2-0_RP20140424\sdtm\xpt_input\*.xpt"; /* create an extra variable 'xptprgs' to contain only the names of the xpt-files */ data work.xptprgs; length filepath $20; infile xptprgs length=reclen; input filepath $varying256. reclen ; xptprgs=reverse(substr(trim(left(reverse(filepath))),5)); run; /* create macro variable 'xptprgs' to capture all individual xpt file names */ proc sql; select xptprgs into: xptprgs separated by ' ' from work.xptprgs ; quit; %put &xptprgs; /* loop through all individual files */ %macro xpt2sas; %do i=1 %to %sysfunc(countw(&xptprgs)); libname xptfile xport "J:\SDTM\c_DefineXML\Define-XML-2-0_RP20140424\sdtm\xpt_input\%scan(&xptprgs, &i).xpt" access=readonly; proc copy inlib=xptfile outlib=sasfile; run; %end; run; %mend xpt2sas; %xpt2sas; Kr, Jacques
... View more