|Date: ||Tue, 27 Oct 2009 22:33:39 -0700|
|Reply-To: ||Tom Abernathy <tom.abernathy@GMAIL.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Tom Abernathy <tom.abernathy@GMAIL.COM>|
|Subject: ||Re: Data Step error handling|
|Content-Type: ||text/plain; charset=ISO-8859-1|
Examples help. If you describe your desired data in terms of
variables ( or columns or fields) and observations (or rows) rather
than as arrays then you will have an easier time mapping those terms
into SAS code and SAS datasets.
If your input was always N lines per observation and fixed format
then use the # pointer on your INPUT statement.
data new; For example if you had 2 lines of text per observation you
could use code like:
input #1 id 1-5 name $ 6-40
#2 age 6-8
But you seem to be describing an input file where each observation
could have a varying number of rows. Usually there are values on the
lines that help you identify when a new observation (subject, sample
or whatever your unit of analysis is) has started. What you can do is
take advantage of the @ and/or @@ syntax on the end of your INPUT
statement to "hold" onto the line so that you can read more.
- Tom Abernathy
On Oct 27, 12:13 pm, Justin <justy...@hotmail.com> wrote:
> i have a flat file with multiple lines per logical record.
> i am tring to use a data step infile to create the dataset from the
> i have defined an array of size N to hold <= N lines.
> if there is a logical record with N+1 lines, the data step stops
> processing the rest
> of the other records follow after this logical record. Reason being
> the array is out of range.
> i have tried various error handling methods from the online manual but
> i am still not able to
> force the data step to continue processing the next record.
> i am not sure how i can overcome this in data step. the logic using a
> programming tool is :
> /*---------- Start -----------------*/
> Open infile
> Read ID
> While ID has not changed, let array(N) = input line, N+1
> if error, print ID + Error reason.
> /*------------ End ---------------*/
> Thank you in advance for any help.
> best regards