So far I've not found an example of what I'm looking for.
I know how to output a CSV file and email it using SAS 9.2 on z/OS using ODS CSV , PROC PRINT, and FILENAME OUTFILE EMAIL. Problem is that for a dataset of even modest size (my dataset was 280K obs with 31 variables), the PROC PRINT processing takes a long time to run and consumes a lot of CPU.
Is there a better way to get a CSV created without printed output from PROC print? My job took 45 minutes and consumed ten minutes of CPU.. For completeness, I did use the uniform and split options to create output that would contain meaningful headers.
I do have access to SAS EG and could probably get it to connect and read this file, but I'm a casual user of that, and only slightly more than a casual user of SAS z/OS...
You can use proc export to create a csv file, its in the documentation.
You could create your csv via dataset and put statements.
I would really suggest however that email is not the way to send data. Firstly it has size limitations and possible ther limitations depending on the IT group. Secondly it is not secure when going anywhere other than internally, and even then may fail audit requirements. Finally its not auditable, i.e. very little traceability. Consider sending your file via FTP server, secure portal or something along those lines.
You may have the SAS supplied %ds2csv macro on your system.
If so something like:
%ds2csv(data=sashelp.class, runmode=B,csvfile=<your path>dummy.csv);
Were you able to solve the issue? I'm facing the same problem 🙂
@marko_kruz wrote:
Were you able to solve the issue? I'm facing the same problem 🙂
You can write a CSV file with a simple data step. If you are running on MVS then lets assume you already have a FILEREF or even just a DDNAME created named CSV that points to where you want the CSV file written. Let's assume the dataset you want to write out is named have.
To write a CSV file without a header line just use:
data _null_;
file csv dsd ;
set have;
put (_all_) (+0);
run;
If you also need to write the header line then add a little bit more code.
proc transpose data=have(obs=0) out=names;
var _all_;
run;
data _null_;
file csv dsd ;
set names ;
put _name_ @ ;
run;
data _null_;
file csv dsd mod;
set have;
put (_all_) (+0);
run;
What about ODS _destination_ none;
ods listing select none;
ods csv file ='...;
proc print data=....;
run;
ods csv close;
ods listing select all;
https://blogs.sas.com/content/iml/2015/05/26/suppress-ods.html
https://blogs.sas.com/content/iml/2022/08/03/ods-destinations-select-list.html
https://blogs.sas.com/content/iml/2015/05/28/five-reasons-ods-exclude.html
Just use a DATA step to write the file.
The particulars for MVS (z/OS) have to go into the FILE statement. RECFM, LRECL etc.
Conversion from EBCDIC to ASCII will be done when the file is downloaded to UNIX/Windows.
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.