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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1888 views
  • 1 like
  • 3 in conversation