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 (March 1998, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 17 Mar 1998 09:35:06 -0500
Reply-To:     WHITLOI1 <WHITLOI1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         WHITLOI1 <WHITLOI1@WESTAT.COM>
Subject:      Re: space in macro text
Comments: To: No_body <dontbother@ANYWHERE.COM>
Content-Type: text/plain; charset=US-ASCII

Subject: space in macro text Summary: Make a macro to handle the task. Respondent: Ian Whitlock <whitloi1@westat.com>

YZ <dontbother@ANYWHERE.COM> asks:

>I have a macro variable that holds a string like 'a1 b1 c1 dd1 >eee1', the spaces between text varies, and so are the text which are less >than 8 digits, how do I made the the length of text plus following spaces >equal to 9 (i.e., 'a1 b1 c1 dd1 eee1 ')? Any >suggestion would be greatly appreciated. Please CC my e-mail when replying >to group.

I would make a macro to handle the task. Given the new tools in 6.11+ it is easy. Here is the log.

72 %macro macex ( inlist = a1 b1 c1 dd1 eee1 , len = 9 ) ; 73 74 %local list w i ; 75 %let i = 1 ; 76 %let w = %qscan ( &inlist , &i ) ; 77 78 %do %while ( &w ^= ) ; 79 %let w = &w%qsysfunc(repeat(%str( ),100)) ; 80 %let list = &list%qsubstr(&w,1,&len) ; 81 %let i = %eval ( &i + 1 ) ; 82 %let w = %qscan ( &inlist , &i ) ; 83 %end ; 84 85 &list 86 %mend macex ; 87 88 %let list = %macex () ; 89 %put >>>%macex()<<< ; >>>a1 b1 c1 dd1 eee1 <<<

Ian Whitlock


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