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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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