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:         Tue, 9 Jan 2007 10:55:23 -0500
Reply-To:     Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject:      Re: Using SCANOVER
Comments: To: ajs2004@BIGFOOT.COM

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'?

Hi, Andrew,

As far as I know, the answer is no. you can easily do something like below, though.

Cheers, Chang

/* assumptions: (1) one line, one variable (2) the last line contains "****" (3) one output obs with latest values or missing */ data one; retain a b c; array v[*] a b c; keep a b c; infile datalines; input; do while (not index(_infile_,"****")); do i = 1 to dim(v); atStr = catt(upcase(vname(v[i])), " is"); loc = index(_infile_, trim(atStr)); if loc>0 then do; value = scan(substr(_infile_, loc+length(atStr)),1); v[i] = input(value, best.); end; end; input; end; output; datalines; A is 1 B is 2 **** ; run;

/* check */ proc print data=one; run; /* on lst Obs a b c 1 1 2 . */


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