hi All,
I am using the code below to convert xpt files to sas files.
However, I see the following error message "ERROR: Libref XPTFILE is not assigned."
Any leadss to resolve this issue?
Thanks
%let path=E:\data\source;
filename xptfiles pipe "dir /b ""&path\%str(*).xpt"" " ;
filename code temp;
data files;
infile xptfiles truncover;
input filename $100. ;
file code;
put 'filename xptfile "&path\' filename +(-1) '" ;';
put 'proc copy inlib=xptfile outlib=ms; run;' ;
run;
libname ms 'E:\data\SAS datasets';
%inc code / source2 ;
Something like:
filename tmp pipe 'dir "c:/mypath/*.xpt" /b"; libname ms "c:/wanttokeeparea"; data _null_; infile tmp; input; call execute(cats('filename xptfile "c:/mypath/',_input_,'")); call execute('proc copy inlib=xptfile outlib=ms; run;');
call execute('filename xptfile clear;'); run;
In preparation for proc copy, use a libname instead of a filename statement. Proc copy is for libraries and not file references.
@Tom; Any comments?
@Kurt_Bremser has already given you the answer.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.