Help using Base SAS procedures

Exporting a SAS data set in SAS format

Accepted Solution Solved
Reply
Regular Contributor
Posts: 216
Accepted Solution

Exporting a SAS data set in SAS format

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;


Accepted Solutions
Solution
‎02-03-2014 08:13 PM
Contributor
Posts: 25

Re: Exporting a SAS data set in SAS format

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


All Replies
Solution
‎02-03-2014 08:13 PM
Contributor
Posts: 25

Re: Exporting a SAS data set in SAS format

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.

Regular Contributor
Posts: 216

Re: Exporting a SAS data set in SAS format

Thanks Rick. I wasn't thinking..

Paul

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 7294 views
  • 2 likes
  • 2 in conversation