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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

5 REPLIES 5
Reeza
Super User

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.

Greek
Obsidian | Level 7

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?

Reeza
Super User

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

libname out 'C:\desktop';

data out.want;

set want;

run;

Tom
Super User Tom
Super User

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;

Greek
Obsidian | Level 7

Thank you all so much! Smiley Happy

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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