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
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;
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.
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.
The transport file is transferred from the source computer to the target computer via communications software or a magnetic medium.
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.
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?
Write the dataset to a library - ie folder that's on your desktop.
libname out 'C:\desktop';
data out.want;
set want;
run;
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;
Thank you all so much!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.