Date: Fri, 25 Apr 2003 15:47:43 -0400
Reply-To: Ian Whitlock <WHITLOI1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <WHITLOI1@WESTAT.COM>
Subject: Re: centering macro text in a title statement where the text leng
th i s variable
Content-Type: text/plain
Amnon,
You must hide single quotes and double quotes from the macro facility when
they do not occur in pairs. Te easies way to do this is to enclose the text
field in %STR(...) and change any ' to %' and any " to %". for example I
tested with
%put %justify(%str(jello%'s jolly, or molly) ,padchar= %str( )) ;
and
data w ; x = 1 ; run ;
title "%justify(%str(jello%'s jolly, or molly))" ;
options nocenter ;
proc print data = w ; run ;
IanWhitlock@westat.com
-----Original Message-----
From: Igra, Amnon [mailto:Amnon.Igra@CORR.CA.GOV]
Sent: Friday, April 25, 2003 12:27 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: centering macro text in a title statement where the text length i s
variable
The following macro, adapted from Ian Whitlock's, works, to center text, as
I needed, in a Title statement. However, some of my text has single quotes
in it, and the macro balks at that. Anyone have any suggestions? I'm not
extremely familiar with all the macro quoting functions.
Thanks for your help.
Amnon Igra
*=======================================================;
%MACRO JUSTIFY (TEXT,PADCHAR = %STR( ) ) ;
%LOCAL NP PAD ;
%LET NP = %EVAL (100 - %LENGTH (&TEXT) ) ;
%LET PAD = %QSYSFUNC ( REPEAT ( &PADCHAR , &NP - 1 ) ) ;
%LET TEXT= %QSUBSTR(&PAD,1,&NP/2)&TEXT%QSUBSTR(&PAD,1,&NP/2);
&TEXT
%MEND JUSTIFY ; *=======================================================;
|