BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ruchita
Calcite | Level 5

Hi All,

I need to convert multiple SAS datasets in one folder to multiple xpt files in another folder.I have used cport but the i dont want to write for each individual dataset.

Request your inputs.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

%let your_libname=put your libname here;

data _null_;

     set sashelp.vtable (where=(LIBNAME="&YOUR_LIBNAME."));            /* Get all dataset names in that library */

     call execute('filename tranfile "put your path to here\'||strip(memname)||'.xpt";       /* Update with your path to */

                          proc cport data=&YOUR_LIBNAME..'||strip(memname)||' file=tranfile;   /* Cport each file to tranfile */

                          run;');

run;

View solution in original post

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

Hi,

%let your_libname=put your libname here;

data _null_;

     set sashelp.vtable (where=(LIBNAME="&YOUR_LIBNAME."));            /* Get all dataset names in that library */

     call execute('filename tranfile "put your path to here\'||strip(memname)||'.xpt";       /* Update with your path to */

                          proc cport data=&YOUR_LIBNAME..'||strip(memname)||' file=tranfile;   /* Cport each file to tranfile */

                          run;');

run;

Ruchita
Calcite | Level 5

hi RW9,

I tried running your code but its not generating xpt. It is not also giving any error or warning.

I get note  : Just 0 obs read from vtable

Thanks,

Ruchita

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Then your putting something wrong in the YOUR_LIBNAME, you need to put a working library which has datasets within it, for example if I wanted sashelp then: % let your_libname=sashelp;

Its where your datasets are.

Ruchita
Calcite | Level 5

Thanks RW9 !! got it .. I am getting the output  .. Thanks a lot  Smiley Happy

paddyb
Quartz | Level 8

Can you pls explain how to do vice versa .I want to convert multiple xpt files into datasets.I am trying to do using xport but no luck.Thanks in advance

libname xylib xport "/home/pbe0/yz142/data/sdtmxpt/*.xpt ";
proc copy in=xylib out=work;
run;

 

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
  • 5 replies
  • 5157 views
  • 2 likes
  • 3 in conversation