View previous topic :: View next topic
|
Author |
Message |
sparrow
New User
Joined: 26 Mar 2007 Posts: 57 Location: Pune
|
|
|
|
Hi ALL,
I have created a SAS report in spool. I need to put this report into a flat file. Can somebody help me on this ? What statement I should add to specify my file ? I have gone thru some SAS guide and found FILENAME and PUT can be used. I tried this but no luck. can someone please give me a hint on this ?
I have used the following code to create the report in spool.
DATA TEST;
INFILE IN;
INPUT
@4 ID $CHAR4.
@45 DEPT $CHAR3.
@100 CODE $CHAR4.
;
PROC PRINT DATA=TEST UNIFORM;
TITLE 'TEST OUTPUT: ';
FOOTNOTE1 '* TEST RUN *' |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
PROC PRINTTO is one possibility.
Generally, if I expect a report to need to go to a file I will not use PROC PRINT but write my own report using DATA _NULL_; so I can specify the file name via a FILE statement. This also gives me much more control over the format of the report. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
PROC PRINTTO Statement i also had in mind.
Some other solutions are :
PROC REPORT
PUT statements with formatting (and yes Robert that is with a null dataset, and a file statement)
There are some nice SAS manuals describing all methods. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You could also use ODS (Output Delivery System) these days but ODS can get very complex depending on what you're wanting to do. |
|
Back to top |
|
|
cpuhawg
Active User
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
|
|
|
|
A PROC PRINT writes to the SASLIST dataset. If you want the report in a flat file, you would direct SASLIST to a permanent file:
Code: |
//SAS.SASLIST DD DSN=HLQ.SASLIST.OUTPUT,
// UNIT=SYSDA,DISP=(NEW,CATLG),
// SPACE=(TRK,(20,10),RLSE)
|
If you want just the records in the flat file, you need to add a DD statement like:
Code: |
//SAS.OUTFILE DD DSN=HLQ.OUTPUT.FILE,
// UNIT=SYSDA,DISP=(,CATLG),
// RECFM=FB,LRECL=14,BLKSIZE=27986,
// SPACE=(TRK,(20,20),RLSE)
|
Then add a step to your SAS program to write to OUTFILE.
Code: |
DATA _NULL_;
SET TEST;
FILE OUTFILE;
PUT @01 ID $CHAR4.
@05 ' '
@06 DEPT $CHAR3.
@09 ' '
@10 CODE $CHAR4.;
|
|
|
Back to top |
|
|
sparrow
New User
Joined: 26 Mar 2007 Posts: 57 Location: Pune
|
|
|
|
cpuhawg,
SAS.OUTFILE is not a DD name in my SAS proc.
Thanks |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
sparrow wrote: |
cpuhawg,
SAS.OUTFILE is not a DD name in my SAS proc.
Thanks |
I believe that he is merely giving examples of how it may be done.
Just because he chooses a DD name that is not in your SAS proc does not stop you from following his examples and adding it ................. does it |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
Quote: |
SAS.OUTFILE is not a DD name in my SAS proc. |
people around here are so eager to be spoon fed that do not even try to understand the concept
even reading a whole post looks consuming
maybe because the price for neuron maintenance is getting higher and highe nowadays |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
cpuhawg, the drawback to redirecting SASLIST is all output for the SAS step will be redirected -- not just the report. If there are other procedures being done in the step, SASLIST would also include their output. |
|
Back to top |
|
|
|