BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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,
7 REPLIES 7
Cynthia_sas
SAS Super FREQ
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]
LinusH
Tourmaline | Level 20
And there is of course options nocenter, which will left align all your output.

/Linus
Data never sleeps
deleted_user
Not applicable
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
LinusH
Tourmaline | Level 20
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
Cynthia_sas
SAS Super FREQ
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
Bob_5150
Calcite | Level 5
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.
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 3560 views
  • 0 likes
  • 4 in conversation