Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can SAS convert CSV files into Binary Format?

Tags:

csv

sas

The output we need to produce is a standard delimited file but instead of ascii content we need binary. Is this possible using SAS?

like image 989
Allan Bowe Avatar asked Aug 02 '26 00:08

Allan Bowe


2 Answers

Is there a specific Binary Format you need? Or just something non-ascii? If you're using proc export, you're probably limited to whatever formats are available. However, you can always create the csv manually.

If anything will do, you could simply zip the csv file.

Running on a *nix system, for example, you'd use something like:

filename outfile pipe "gzip -c > myfile.csv.gz";

Then create the csv manually:

data _null_;
   set mydata;
   file outfile;
   put var1 "," var2 "," var3;
run;

If this is PC/Windows SAS, I'm not as familiar, but you'll probably need to install a command-line zip utility.

This link from SAS suggests using winzip, which has a freely downloadable version. Otherwise, the code is similar. http://support.sas.com/kb/26/011.html

like image 87
Neil Neyman Avatar answered Aug 05 '26 05:08

Neil Neyman


You can actually make a CSV file as a SAS catalog entry; CSV is a valid SAS Catalog entry type.

Here's an example:

filename of catalog "sasuser.test.class.csv";

proc export data=sashelp.class
   outfile=of
   dbms=dlm;
   delimiter=',';
run;

filename of clear;

This little piece of code exports SASHELP.CLASS to a SAS Catalog entry of entry type CSV.

This way you get a binary format you can move between SAS installations on different platforms with PROC CPORT/CIMPORT, not having to worry if the used binary package format is available to your SAS session, since it's an internal SAS format.

like image 35
Martin Bøgelund Avatar answered Aug 05 '26 03:08

Martin Bøgelund