Need to convert multiple SAS datasets at one location to multiple xpt files in another folder

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Need to convert multiple SAS datasets at one location to multiple xpt files in another folder

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


Accepted Solutions
Solution
‎07-10-2014 05:54 AM
Super User
Super User
Posts: 7,414

Re: Need to convert multiple SAS datasets at one location to multiple xpt files in another folder

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


All Replies
Solution
‎07-10-2014 05:54 AM
Super User
Super User
Posts: 7,414

Re: Need to convert multiple SAS datasets at one location to multiple xpt files in another folder

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;

Occasional Contributor
Posts: 9

Re: Need to convert multiple SAS datasets at one location to multiple xpt files in another folder

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

Super User
Super User
Posts: 7,414

Re: Need to convert multiple SAS datasets at one location to multiple xpt files in another folder

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.

Occasional Contributor
Posts: 9

Re: Need to convert multiple SAS datasets at one location to multiple xpt files in another folder

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

Contributor
Posts: 33

Re: Need to convert multiple SAS datasets at one location to multiple xpt files in another folder

[ Edited ]

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;

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 1083 views
  • 1 like
  • 3 in conversation