tags:

views:

493

answers:

4

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

+3  A: 

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

Neil Neyman
A: 

Are you saying you have binary data that you want to output to csv?

If so, I don't think there is necessarily a defined standard for how this should be handled.

I suggest trying it (proc export comes to mind) and seeing if the results match your expectations.

Rog
I am saying I have a csv I want to output as binary. My thought was that 'binary format' is something standardised like csv or other delimited. I realise now this isn't the case - have requested more info on the nature of the 'binary format' we need to replicate..
Bazil
A: 

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.

Martin Bøgelund
A: 

Using SAS, output a .csv file; Open it in Excel and Save As whichever format your client wants. You can automate this process with a little bit of scripting in ### as well. (Substitute ### with your favorite scripting language.)

Chang Chung