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 (January 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 10 Jan 2007 08:21:34 -0800
Reply-To:     shiling99@YAHOO.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         shiling99@YAHOO.COM
Organization: http://groups.google.com
Subject:      Re: Using SCANOVER
Comments: To: sas-l@uga.edu
In-Reply-To:  <1168430435.707156.136090@i39g2000hsf.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"

It seems to me that there is a 'BUG' in there.

SAS doc ******************************************** SCANOVER causes the INPUT statement to scan the input data records until the character string that is specified in the @'character-string' expression is found.

Interaction: The MISSOVER, TRUNCOVER, and STOPOVER options change how the INPUT statement behaves when it scans for the @'character-string' expression and reaches the end of the record. By default (FLOWOVER option), the INPUT statement scans the next record while these other options cause scanning to stop. ********************************************** The SAS doc says TRUNCOVER will interact with SCANOVER. It is NOT.

Here is a workaround patch.

data a; infile datalines scanover; input @; if index(_infile_,'A is') then input @1 @'A is' a @; if index(_infile_,'B is') then input @1 @'B is' b @; if index(_infile_,'C is') then input @1 @'C is' c @; output; datalines; A is 1 B is 2 B is 2 B is 2 A is 1 B is 2 ; run;

proc print; run;

HTH

ajs2...@bigfoot.com wrote: > Thanks to everyone who suggested answers - three workable solutions > that all deliver the data. > > For my purpose, Howard Schreier's solution was ideal, with the simplest > program and minimal change to the code. > > Andrew > > > "Howard Schreier <hs AT dc-sug DOT org>" wrote: > > On Tue, 9 Jan 2007 05:33:25 -0800, ajs2004@BIGFOOT.COM wrote: > > > > >Suppose I have a really simple data step like this: > > > > > > data; > > > infile datalines missover; > > > input a b c; > > > datalines; > > > 1 2 > > > ; > > > run; > > > > > >which gives me the data set I want (with one observation, and the value > > >of C is missing). > > > > > >Now suppose I have this: > > > > > > data; > > > infile datalines scanover; > > > input @'A is' a @'B is' b @'C is' c; > > > datalines; > > > A is 1 > > > B is 2 > > > ; > > > run; > > > > > >I get no observations, and the log shows > > > > > > NOTE: LOST CARD. > > > a=1 b=2 c=. _ERROR_=1 _N_=1 > > > > > >But what I want is to have that observation, even if the end of the > > >file was reached without C being found - just as in the first example, > > >I got the observation even though the end of the input line was reached > > >without C being found. > > > > > >Is there an easy way to do this - I mean, without giving up the > > >convenience of using SCANOVER and @'string'? > > > > > >Andrew > > > > Use the EOF= option. > > > > data; > > infile datalines scanover EOF=NOMORE ; > > input @'A is' a @'B is' b @'C is' c; > > NOMORE: OUTPUT ; > > datalines; > > A is 10 > > B is 20 > > C is 30 > > A is 1 > > B is 2 > > ; > > > > Output: > > > > Obs a b c > > > > 1 10 20 30 > > 2 1 2 .


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