The SAS Output Delivery System and reporting techniques

Exporting SAS data sets

Accepted Solution Solved
Reply
Contributor
Posts: 45
Accepted Solution

Exporting SAS data sets

Good afternoon,

I am trying to export a data set from a SAS environment into a windows environment (Desktop). I am using the following code, which seems to work, but the resulting data set is unusable. Do you happen to know what's wrong with this code? Or a way to perform this very simple task?  

Thank you!

Code:

proc cport data=frequency file='C:\Users\loukakis\Desktop\opa\different';

run;

LOG:

NOTE: PROC CPORT begins to transport data set WORK.FREQUENCY

NOTE: The data set contains 706 variables and 485 observations. Logical record length is 91304.

NOTE: PROCEDURE CPORT used (Total process time):

      real time           0.11 seconds

      cpu time            0.10 seconds

Error Message when I try to open the file:

Could not open data file: Error:

file TMP1.DIFFERENT.DATA is not a SAS data set


Accepted Solutions
Solution
‎08-21-2015 01:04 PM
Super User
Super User
Posts: 6,845

Re: Exporting SAS data sets

Just save the dataset where you want it. The extension will by .sas7bdat .

data 'C:\Users\loukakis\Desktop\opa\different\frequency';

  set frequency;

run;

or you can use libref.

LIBNAME out 'C:\Users\loukakis\Desktop\opa\different';

data out.frequency;

  set frequency;

run;

or

LIBNAME out 'C:\Users\loukakis\Desktop\opa\different';

proc copy inlib=work outlib=out ;

  select frequency ;

run;

View solution in original post


All Replies
Super User
Posts: 19,157

Re: Exporting SAS data sets

What do you want your output dataset to be, a SAS dataset?

If you use CPORT you need to use CIMPORT to import the file.

Overview: CPORT Procedure

What Does the CPORT Procedure Do?

The CPORT procedure writes SAS data sets, SAS catalogs, or SAS libraries to sequential file formats (transport files). Use PROC CPORT with the CIMPORT procedure to move files from one environment to another. Transport files are sequential files that each contain a SAS library, a SAS catalog, or a SAS data set in transport format. The transport format that PROC CPORT writes is the same for all environments and for many releases of SAS. In PROC CPORT, export means to put a SAS library, a SAS catalog, or a SAS data set into transport format. PROC CPORT exports catalogs and data sets, either singly or as a SAS library. PROC CIMPORT restores (imports) the transport file to its original form as a SAS catalog, SAS data set, or SAS library.

PROC CPORT also converts SAS files, which means that it changes the format of a SAS file from the format appropriate for one version of SAS to the format appropriate for another version. For example, you can use PROC CPORT and PROC CIMPORT to move files from earlier releases of SAS to more recent releases. PROC CIMPORT automatically converts the transport file as it imports it.

Note: PROC CPORT and PROC CIMPORT can be used to back up graphic catalogs. PROC COPY cannot be used to back up graphic catalogs.

PROC CPORT produces no output (other than the transport files), but it does write notes to the SAS log.

Process for Creating and Reading a Transport File

Here is the process to create a transport file at the source computer and to read it at a target computer:

  1. A transport file is created at the source computer using PROC CPORT.

  2. The transport file is transferred from the source computer to the target computer via communications software or a magnetic medium.

  3. The transport file is read at the target computer using PROC CIMPORT.Note: Transport files that are created using PROC CPORT are not interchangeable with transport files that are created using the XPORT engine.

For complete details about the steps to create a transport file (PROC CPORT), to transfer the transport file, and to restore the transport file (PROC CIMPORT), see Moving and Accessing SAS Files.

Contributor
Posts: 45

Re: Exporting SAS data sets

Thank you very much for your response! I have been asked for the data sets in SAS format for the first time (they are usually fine with excel) and I have never done this before. Is there a way to create sas data sets without asking them to use the CIMPORT procedure?

Super User
Posts: 19,157

Re: Exporting SAS data sets

Write the dataset to a library - ie folder that's on your desktop.

libname out 'C:\desktop';

data out.want;

set want;

run;

Solution
‎08-21-2015 01:04 PM
Super User
Super User
Posts: 6,845

Re: Exporting SAS data sets

Just save the dataset where you want it. The extension will by .sas7bdat .

data 'C:\Users\loukakis\Desktop\opa\different\frequency';

  set frequency;

run;

or you can use libref.

LIBNAME out 'C:\Users\loukakis\Desktop\opa\different';

data out.frequency;

  set frequency;

run;

or

LIBNAME out 'C:\Users\loukakis\Desktop\opa\different';

proc copy inlib=work outlib=out ;

  select frequency ;

run;

Contributor
Posts: 45

Re: Exporting SAS data sets

Thank you all so much! Smiley Happy

🔒 This topic is solved and locked.

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

Discussion stats
  • 5 replies
  • 584 views
  • 3 likes
  • 3 in conversation