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

Hi

I would like to export a SAS data set keeping it in SAS format (sas7bdat). I have tried variations of PROC EXPORT below and none seem to work. Has anyone used the CPORT proc for this?

Paul

proc export data=work.surrenderTprCount

   outfile='F:\MetricFiles\9_2013'

DBMS=sas

      replace;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
rickpaulos
Obsidian | Level 7

Do you want to make a copy in a different folder or on a different drive with the same data set name?

DATA "samedrive:\NEWfoldername\samedatasetname";

  SET "samedrive:\OLDfoldername\samedatasetname";

RUN;

DATA "Newdrive:\foldername\samedatasetname";

  SET "Oldrive:\foldername\samedatasetname";

RUN;

You could use two LIBNAME statements instead (can be useful for lengthy programs with many data set references or if you move your files around often) :

LIBNAME oldlocation "C:\myfolder\sas\work";

LIBNAME newlocation "F:\MetricFiles";

DATA newlocation.samedatasetname;

  SET oldlocation.samedatasetname;

RUN;

Or just use windows explorer (MY Computer or Computer) to just move or copy the file directly (click and drag).  You won't mess up a sasb7dat file by moving it.  SASb7dat files don't normally contain their own location within themselves.

If you are just trying to rename the data set name.

DATA libraryname.NEWname;

  SET libraryname.OLDname;

RUN;

BTW.  "work." is the default location, you don't have to specify that.  ie:  data=work.surrenderTprCount is the same as data=surrenderTprCount

PS, PROC IMPORT, EXPORT, CPORT, CINPORT are intended to change the format.  They have plenty of traps waiting for you.

View solution in original post

2 REPLIES 2
rickpaulos
Obsidian | Level 7

Do you want to make a copy in a different folder or on a different drive with the same data set name?

DATA "samedrive:\NEWfoldername\samedatasetname";

  SET "samedrive:\OLDfoldername\samedatasetname";

RUN;

DATA "Newdrive:\foldername\samedatasetname";

  SET "Oldrive:\foldername\samedatasetname";

RUN;

You could use two LIBNAME statements instead (can be useful for lengthy programs with many data set references or if you move your files around often) :

LIBNAME oldlocation "C:\myfolder\sas\work";

LIBNAME newlocation "F:\MetricFiles";

DATA newlocation.samedatasetname;

  SET oldlocation.samedatasetname;

RUN;

Or just use windows explorer (MY Computer or Computer) to just move or copy the file directly (click and drag).  You won't mess up a sasb7dat file by moving it.  SASb7dat files don't normally contain their own location within themselves.

If you are just trying to rename the data set name.

DATA libraryname.NEWname;

  SET libraryname.OLDname;

RUN;

BTW.  "work." is the default location, you don't have to specify that.  ie:  data=work.surrenderTprCount is the same as data=surrenderTprCount

PS, PROC IMPORT, EXPORT, CPORT, CINPORT are intended to change the format.  They have plenty of traps waiting for you.

Paul_NYS
Obsidian | Level 7

Thanks Rick. I wasn't thinking..

Paul

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 36226 views
  • 2 likes
  • 2 in conversation