LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 16 Sep 2009 08:52:02 -0400
Reply-To:   Lou <lpogoda@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Lou <lpogoda@HOTMAIL.COM>
Organization:   A noiseless patient Spider
Subject:   Re: Simulating a title with the PUT statement XXX
Comments:   To: sas-l@uga.edu

To center a string on a line, you get the starting position by taking the length of the line, subtract the length of the string, divide by two, and drop any fractional portion of the result. This all assumes you're using a fixed-width font.

So if the length of the line in your print file is 132 characters, you could do something like:

%let i = per protocol; data _null_; file print; string = "results for sub-population &i"; start = int((132 - length(string))/2); put @start string; stop; run;

If you want to follow Gerhard's suggestion, the hex byte he's probably thinking of is 'A0';

%let i = per protocol; title1 "results for sub-population &i"; data _null_; file print; put 'a0'x; stop; run;

A slight caution here - if ultimately people are going to view you print file in a word processor program, hex byte A0 appears as a blank in Microsoft Word. However, in the Writer application from Open Office, the byte shows up as a gray character cell by default. Don't know about other word processing programs.

"Gerhard Hellriegel" <gerhard.hellriegel@T-ONLINE.DE> wrote in message news:200909161143.n8GAkfmk004522@malibu.cc.uga.edu... > if you have something to list, why don't you use a title statement? > If you have nothing and want only the title, you must use a char which is > not visible, but not blank. I think hex FF or ED (somewhere around that) > is something what you could use to force SAS to produce a output. > > title "Results for Subpopulation #&I:"; > > DATA _NULL_; > FILE PRINT; > PUT "."; PUT ; PUT; > RUN; > > Gerhard > > > > On Wed, 16 Sep 2009 03:44:34 -0400, Dan Abner <dan.abner99@GMAIL.COM> > wrote: > >>Hello, >> >>Does anyone know how to center a character string in the listing and print >>it in blue using a PUT statment (In other words, to mimick a title)? >> >>I have the following DATA step that I use in what I hope will be a >>production level macro. Just need this to look like a proper title. I > would >>rather not call a null PROC step just to get a title to print... >> >>DATA _NULL_; >> >>FILE PRINT; >> >>PUT; PUT "Results for Subpopulation #&I:"; PUT; >> >>RUN; >> >>Thanks! >> >> >> >>Daniel


Back to: Top of message | Previous page | Main SAS-L page