Date: Thu, 15 Sep 2011 15:00:04 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: Need help for infile statement
In-Reply-To: <CAAYPvJG5JsH2Dmq5JrHc6-iZNLi+dBNW6fF5d6V+eeSksn3GmA@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
http://support.sas.com/kb/38/147.html
On Thu, Sep 15, 2011 at 2:44 PM, ST <sheepsas@gmail.com> wrote:
> Hi there,
>
> I have to read a file which use '|~' as the delimiter, three variables, the
> dataset has three variables: V1(CHAR2), V2(CHAR10), V3(CHAR17), like this
>
> C|~26248476|~20028102659054000|~
> T|~26248484|~20028102659062000|~
> |~26248490|~20028102659068000|~
> B|~26248497|~20028102659076000|~
>
> Here is my code:
> data base;
> infile 'id.txt' MISSOVER DLMSTR="|~" DSD;
> length
> V1 $2
> V2 $10
> V3 $17
> ;
> input
> V1 $
> V2 $
> V3 $
> ;
> run;
> Proc print; run;
>
> the V2 of the 3rd obs is not correct.
>
> Result:
> Obs V1 V2 V3
>
> 1 C 26248476 20028102659054000
> 2 T 26248484 20028102659062000
> 3 ~26248490 20028102659068000
> 4 B 26248497 20028102659076000
>
>
> now what I can do is to use
> infile 'id.txt' MISSOVER DLM="|" DSD;
>
> Result:
> Obs V1 V2 V3
>
> 1 C ~26248476 ~2002810265905400
> 2 T ~26248484 ~2002810265906200
> 3 ~26248490 ~2002810265906800
> 4 B ~26248497 ~2002810265907600
>
>
> and use substr function to get rid of the first character from V2 and V3.
>
> Any suggestions to read without using substr function?
>
> Thanks in advance,
>
> Hu
>
|