PROBLEM:
I need to write out data from my SAS Data Set to a raw data file.
What do I do?
*********************************************************
SOLUTION:
1) Enter a LIBNAME statement that tells SAS where the OLD library is,
for example:
LIBNAME OLD 'C:\SASDATA'; *** Windows or SAS-PC example;
LIBNAME OLD '~/SASDATA'; *** UNIX example;
2) Enter a FILENAME statement which points to a UNIX or DOS file
to hold the output raw data, as in these examples:
FILENAME nikname 'C:\RAWDATA\MYOUT.RAW'; *** Windows or SAS-PC;
FILENAME nikname '~/rawdata/myout.raw'; *** UNIX;
3) Then add this basic program after your LIBNAME and FILENAME statements:
DATA new;
SET old.sasdata;
FILE nikname;
PUT @ VAR1 @ VAR2 ... @ VARn;
RUN;
Where the @'s in the PUT statement followed by a column number "point"
to those specific columns. For example,
PUT @1 VAR1 @5 VAR2;
would place VAR1 beginning in column 1 and VAR2 would start in column 5.
The FILE statement directs the 'output' from the PUT statement
into the file referenced by 'nikname', which is where you will find
your raw data when this program is finished.
========================================================================
Here are two complete examples, based on the programs above:
UNIX
----
LIBNAME OLD '~/SASDATA';
FILENAME nikname '~/rawdata/myout.raw';
DATA new;
SET old.sasdata;
FILE nikname;
PUT @1 VAR1 @5 VAR2;
RUN;
Windows/SAS-PC (DOS)
--------------------
LIBNAME OLD 'C:\SASDATA';
FILENAME nikname 'C:\RAWDATA\MYOUT.RAW';
DATA new;
SET old.sasdata;
FILE nikname;
PUT @1 VAR1 @5 VAR2;
RUN;