BookmarkSubscribeRSS Feed
ari
Quartz | Level 8 ari
Quartz | Level 8

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 ;


 

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;
ari
Quartz | Level 8 ari
Quartz | Level 8

@Tom; Any comments?

Tom
Super User Tom
Super User

@Kurt_Bremser has already given you the answer.

LinusH
Tourmaline | Level 20
Just a thought, given the filename extension, perhaps this file should be read by either PROC CIMPORT or the libname xport engine?
Data never sleeps

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2900 views
  • 0 likes
  • 5 in conversation