Date: Thu, 22 Apr 2004 16:11:07 -0400
Reply-To: "Lustig, Roger" <roger.lustig@CITIGROUP.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Lustig, Roger" <roger.lustig@CITIGROUP.COM>
Subject: Re: Searching backward through a file.
Content-Type: text/plain; charset="iso-8859-1"
Don:
I think the problem is that some of the code generators don't work there any more. Some, if not all, of the 44K lines may be human-generated.
Roger
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of Don
& Susann
Sent: Thursday, April 22, 2004 4:07 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Searching backward through a file.
But you didn't write 44,000 lines of code did you? What was used to
generate the code .. is it easier to examine the code generators to look
for this? Is the whole program a single data step (assuming your unbal
parenthesis are in a data step?) or a series of data steps?
If the pseudo code your presented were possible, you would not need to
search from the bottom, only from where the unbalanced parenthesis error
was reported.
Hard one to sort out! I know how difficult it can to sort out code
created by code generators, assuming thats what you do. My technique
whenever possible is to comment out pieces of datastep, and gradually
add more and more to the commented out code until the error no longer
occurs. Then you have a good idea of where to examine the code in
detail. But be wary, this can induce other errors.
Good luck!
Don
Ed Heaton wrote:
> Richard,
>
> The code that I often have to debug can have statements that span dozens of
> lines and the files are tens of thousands of lines long. (The current one
> is 44 thousand lines of code!
>
> Ed
>
> -----Original Message-----
> From: Richard A. DeVenezia [mailto:radevenz@ix.netcom.com]
> Sent: Thursday, April 22, 2004 12:05 PM
> To: Ed Heaton
> Subject: Re: Searching backward through a file.
>
>
> Ed Heaton wrote:
>
>>Good morning, all;
>>
>>I am trying to create a little job to search SAS code for unbalanced
>>parentheses. The following will alert me if I have an extra right
>>parenthesis.
>>
>>Data _null_ ;
>> InFile sasCode end=eof ;
>> Input ;
>> If not missing(_inFile_) then do i=1 to length(_inFile_) ;
>> Select ( rank( subStr( _inFile_ , i , 1 ) ) ) ;
>> When (40) leftParen + 1 ;
>> When (41) rightParen + 1 ;
>> Otherwise ;
>> End ;
>> If ( leftParen lt rightParen ) then put _all_ ;
>> End ;
>> If eof then call symPut( "n" , put( _n_ , best. ) ) ;
>>Run ;
>>
>>Now I want to search for an extra left parenthesis. I envision
>>starting at the bottom of the file and searching backward. Something
>>like...
>>
>>Data _null_ ;
>> Retain N &n ;
>> InFile sasCode ;
>> /* Go to the bottom of the file. */
>> Input #N ;
>> N + -1 ;
>> If not missing(_inFile_) then do i=length(_inFile_) to 1 by -1 ;
>> Select ( rank( subStr( _inFile_ , i , 1 ) ) ) ;
>> When (40) leftParen + 1 ;
>> When (41) rightParen + 1 ;
>> Otherwise ;
>> End ;
>> If ( leftParen gt rightParen ) then put _all_ ;
>> End ;
>> If ( _n_ eq &n ) then stop ;
>>Run ;
>>
>>Of course, this doesn't work. Is there a way to make SAS read
>>backward through a file. My other option is to write each line from
>>the first read into a data set, reverse the order of the data set,
>>and use it in the second DATA step. This seems very clunky to me.
>>Any suggestions?
>>
>>Ed
>>
>>Edward Heaton, SAS Senior Systems Analyst,
>>Westat (An Employee-Owned Research Corporation),
>>1600 Research Boulevard, RW-3541, Rockville, MD 20850-3195
>>Voice: (301) 610-4818 Fax: (301) 610-5128
>>mailto:EdHeaton@Westat.com http://www.Westat.com
>
>
> Ed:
>
> unbalanced is number of opens NE number of closes ;)
>
> Of course this code would never work for me. My large parenthetical
> expressions are usually spread across several lines. Then there is the
> issue of comments and escaped context in macro, e.g. %(
>
>
> Richard A. DeVenezia
>
>
--
Don Stanley, B.SC, Dip O.R.S, MNZCS
Author:: Beyond the obvious with SAS Screen Control Language.
Author:: Solutions for your GUI Applications Development Using SAS/AF
FRAME Technology
http://www.syswaregroup.com , http://homepages.rootsweb.com/~ashluke
|