Desktop productivity for business analysts and programmers

How to generate a text file

Reply
Frequent Contributor
Posts: 97

How to generate a text file

Hi Cynthia

I you were to generate a text based report, i.e a physical file is supposed to be created what code will u use in EG.

I report that is a .txt file

Using PROC REPORT for a text file, can you
1. Give report headers and footers
2. Wrap column text
3. Give customised total and sub total labels
4. How to give report headers and report footers (NOT page headers and page footers)

sorry for repeating the question.
SAS Super FREQ
Posts: 8,814

Re: How to generate a text file

Hi:
To use a "click-path" in EG to create a LIST file (LISTING destination -- ASCII text file), you would do the following:
[pre]
Tools --> Options
Results General
Deselect (uncheck) ALL the check boxes for HTML, PDF, RTF and SAS Report
Select (check) the box for Text output
Create your new project and/or new task
[/pre]

IF you have made this selection (for Text output) in Options, then you do NOT need to submit any additional code in order to get LISTING destination -- ASCII text output.

HOWEVER, if you do NOT change options and you have another output type chosen (like HTML or RTF), -and- you are going to submit code, then you may need to close all open ODS destinations in your code (ODS _ALL_ CLOSESmiley Wink and then explicitly open the LISTING destination (ODS LISTING; in code below):
[pre]
ods _all_ close;
ods listing;
proc print data=sashelp.shoes(obs=10);
title "Should Be Listing -- TEXT output";
run;
[/pre]

If you need to write your output to a TXT file, then you would do this:
[pre]
ods _all_ close;
ods listing file='c:\temp\somefile.txt';
proc print data=sashelp.shoes(obs=10);
title "Should Be Listing -- TEXT output";
run;
ods listing;
[/pre]

For more help creating ASCII text output or ASCII text files, you might consider contacting Tech Support for more help with how to do this in EG.

cynthia

PS...the above technique is for EG ONLY -- not for creating a stored process that returns TEXT output.

PPS -- that's for how to create a TXT file in EG. I know I showed PROC PRINT, but I'll answer your PROC REPORT question in a separate post.
SAS Super FREQ
Posts: 8,814

Re: How to generate a text file

Hi, Grasshopper:
Here's part 2. Your PROC REPORT specific questions (my answers are in bold underneath your numbered questions):

Using PROC REPORT for a text file, can you
1. Give report headers and footers
yes depending on your destination and your technique (whether you were using BY group processing or not), you could either use compute before and compute after or compute before _page_ and compute after _page_ to get what some people consider to be REPORT headers and REPORT footers (where the text is -inside- the boundary of the table area).

2. Wrap column text
Yes -- in LISTING destination, ASCII text file using FLOW and WIDTH options
Yes -- in RTF, PDF and HTML destinations using CELLWIDTH example
See the table at the end of this posting:
http://support.sas.com/forums/thread.jspa?messageID=7442ᴒ
and this one
http://support.sas.com/forums/thread.jspa?messageID=7408ᳰ (Example 1 program)


3. Give customised total and sub total labels
yes, using COMPUTE blocks. See this prior forum posting, when the word 'SubTotal' or some customized text was changed at the break:
http://support.sas.com/forums/thread.jspa?threadID=1796&tstart=0
and this one
http://support.sas.com/forums/thread.jspa?threadID=1827&tstart=0
and
Example 2 program in this prior posting:
http://support.sas.com/forums/thread.jspa?messageID=7408ᳰ


4. How to give report headers and report footers (NOT page headers and page footers)
I do not understand how this question for #4 is different from what you asked in #1. In either case, the Example 2 program at this post,
http://support.sas.com/forums/thread.jspa?messageID=7408ᳰ
showed customizing breaks (Asia SubTotal), showed how to use COMPUTE BEFORE breakvar and COMPUTE BEFORE _PAGE_. As I said in #1 depending on your destination and whether you were using BY group processing, EITHER of these COMPUTE blocks might produce something that can be considered a REPORT HEADER (not the kind of PAGE header that comes from the SAS title. If you run the program and create the output file of your choice -- ASCII text, vs HTML, vs RTF, vs PDF -- then you will see by comparing the output how the different syntax produces different results in different destinations.
[pre]
compute before _page_;
line "Before Report Table";
endcomp;
compute before region;
line "Before Region";
endcomp;
[/pre]


At this point, in order to understand how PROC REPORT works, the only thing for you to do is to work with PROC REPORT or take a class or read the documentation to try to figure out what it is you want to do. One place to start would be with the code samples that have been previously posted and the code samples in the SAS help topics and the code samples in various user-group papers and to use them and study them and experiment with them until you get the end results you want -- or close to the end results you want.

Good PROC REPORT help topics are entitled:
Creating Detail and Summary Reports with the REPORT Procedure
Overview: REPORT Procedure
Concepts: REPORT Procedure
How PROC REPORT Builds a Report

A good SUGI/User-group paper on the subject of PROC REPORT is:
http://www.lexjansen.com/pharmasug/2005/handsonworkshops/hw07.pdf (Art Carpenter tutorial)

Another good source of help is the Tech Support FAQ. If you search the Tech Support FAQ for "PROC REPORT", there are 700+ hits on frequently asked questions about PROC REPORT.

If you have an immediate need, then your only other choice is to contact Tech Support for further help. If you are having problems with code that's been posted, then Tech Support can help you figure out how to modify these code examples for your particular need.

cynthia
Ask a Question
Discussion stats
  • 2 replies
  • 105 views
  • 0 likes
  • 2 in conversation