BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

 

I am using the below pgm to convert xpt files in a folder to sas datasets. The pgm is working fine. But i can only do one data set at a time. Please suggest me how to modify my pgm to convert all datasets.  In the below pgm i am converting ae xpt file. What information i need to add in place of ae to work on all data sets.

libname tmp pipe "dir /b ""abc/ddd/%str(*).xpt""";
libname ms "abc/ddd";

data _null_;
  infile tmp;
  input;
  call execute(cats('libname xptfile xport "abc/ddd/','ae','.xpt";'));
  call execute('proc copy inlib=xptfile outlib=ms; run;');
  call execute('filename xptfile clear;');
run;
2 REPLIES 2
jimbarbour
Meteorite | Level 14

Hmmm.  Shouldn't the first Libname be a Filename?  

 

Your code shouldn't need much in the way of a change if it's already working.  You should just be able to change:

  1. Add the TRUNCOVER option to your INFILE.
  2. Add a variable name and informat to your INPUT statement
  3. Modify your CALL EXECUTE statement as shown below.

Jim

 

FILEname tmp pipe "dir /b ""abc/ddd/%str(*).xpt""";
libname ms "abc/ddd";

data _null_;
  infile   tmp    TRUNCOVER;
  input    Dir_Listing    $256.;
  call execute(cats('libname xptfile xport "abc/ddd/', Dir_Listing, '";'));
  call execute('proc copy inlib=xptfile outlib=ms; run;');
  call execute('filename xptfile clear;');
run;

 

PaigeMiller
Diamond | Level 26

Also, I don't think you need %str(*)

 

FILEname tmp pipe "dir /b ""abc/ddd/*.xpt""";

or even simpler

FILEname tmp pipe "dir /b abc/ddd/*.xpt";

 

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 2 replies
  • 1523 views
  • 1 like
  • 3 in conversation