Help using Base SAS procedures

Proc Printto print = txt

Reply
N/A
Posts: 0

Proc Printto print = txt

Dear SAS,

While using Proc Printto ; I am facing these issues , Any way out for these

Proc Printto print = txt
1) How to do Left & Right Alignment of header and footer
2) Left & Right Alignment for columns and data corresponding to the Column
3) if I reduce the line size then it trunc the output from right side which is loss of data.

Thanks in advance for your reply.

Regards,
SAS Super FREQ
Posts: 8,861

Re: Proc Printto print = txt

Posted in reply to deleted_user
Hi:
An ASCII text file, such as that produced by PROC PRINTTO does not offer much in the way of cosmetic improvement, such as data, column, or header alignment.

If you are producing the PRINTTO output from a SAS procedure, then in your viewer (such as Notepad or Word), when you open the file, you can see the output, as SAS created it, by choosing to display the file in the SAS Monospace font at 8 or 9 pt.

For example, if I run the program below (note the special justifications applied in PROC REPORT), I can only see the justifications, if I change my Notepad font to SAS Monospace 9 pt when I view the file.

If you need to create files that can have alignment formatting, can have page breaks and can be easily printed, you may want to consider using ODS PDF or ODS RTF destinations (instead of PROC PRINTTO).

cynthia
[pre]
options linesize=141 pagesize=44 nodate nonumber;
proc printto file='c:\temp\myreport.txt';
run;

** View this file in Notepad, but you must change the Notepad;
** font to SAS Monospace 9 PT to see alignment respected.;
proc report data=sashelp.class nowd;
title 'The Centered Title in the LINESIZE';
column name age height;
define name / 'Name' right;
define age / 'The Age' center f=3.0 width=7;
define height / 'Height' left f=4.1 width=6;
run;

proc printto;
run;
[/pre]
Super User
Posts: 5,424

Re: Proc Printto print = txt

Posted in reply to Cynthia_sas
And there is of course options nocenter, which will left align all your output.

/Linus
Data never sleeps
N/A
Posts: 0

Re: Proc Printto print = txt

Posted in reply to deleted_user
Thanks for your reply,

I want to generate the report in text format with these :

1) Left & Right Alignment of header and footer
2) Left & Right Alignment for columns and data corresponding to the Column


Thanks
Super User
Posts: 5,424

Re: Proc Printto print = txt

Posted in reply to deleted_user
Numeric columns are right-aligned, and character columns are left aligned by default. Numerical column cold be left aligned by converting them to char format.

Another possibility is if you use data step reporting, where you have more possibilities to format your output. But this is quite time-consuming, and the report will be fixed to text reporting only. So a more generic and flexible approach is to have a look at ODS functionality, as Cynthia mentioned.

/Linus
Data never sleeps
SAS Super FREQ
Posts: 8,861

Re: Proc Printto print = txt

Posted in reply to deleted_user
Hi:
If you run my test program AND if you view the resulting TEXT file in Notepad or Word with SAS Monospace font, 9pt, you WILL see that the alignment specified in the PROC REPORT code has been applied.

If you look at the text file in any viewer with a proportional font, it will not look like it did when SAS created it. You MUST view the file with SAS Monospace 9pt to see the alignment (or Courier New will probably work).

cynthia
N/A
Posts: 1

Re: Proc Printto print = txt

Posted in reply to Cynthia_sas
Hi Cynthia,
How do you change from SAS Monospace Font 9pt to something else.
I just installed 9.1.3 and the proc printto is not what i expected...

I would like to use a font that everyone i send it to will be able to open it and know what it is.
SAS Super FREQ
Posts: 8,861

Re: Proc Printto print = txt

Hi:
PROC PRINTTO creates an ASCII text file. Any font settings belong to the viewer you use when you open the text file. Therefore, SAS does not have any control over the font of the text in the ASCII text file.

"ASCII text file A file which consists of a series of lines terminated by a hard carriage return and which contains no formatting information and can thus be read by any text editor. Most word processors have a mode for reading and writing ASCII text files, i.e. for suppressing the formatting information, page layout, page breaks, typeface attributes, etc. which they normally include in the text files they create."
from: http://www.uni-due.de/CP/key_terms.htm

I don't really understand exactly what you want or need to do. However, in my experience, most folks who email SAS results to other people use the Output Delivery System. If you create an RTF or PDF or HTML file, then the output will contain formatting instructions such as a font specification. In addition, if you sent a PDF file, the PDF file would be "printer-ready".

ODS uses the same "sandwich" technique as PROC PRINTTO. For example, if you wanted to create a PDF file for mailing, you could do this:
[pre]
ODS PDF file='c:\temp\mailthis.pdf';

proc print data=sashelp.class;
run;

ODS PDF CLOSE;
[/pre]

ODS PDF uses either Helvetica or Times New Roman in SAS 9.1.3, which are fonts available on most computer systems. Once the PDF file is created, you can then mail the file. Similar syntax could be used for ODS RTF or ODS HTML output results.

cynthia
Ask a Question
Discussion stats
  • 7 replies
  • 817 views
  • 0 likes
  • 4 in conversation