Date: Mon, 22 Nov 2010 13:39:46 -0800
Reply-To: Daniel Nordlund <djnordlund@FRONTIER.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Daniel Nordlund <djnordlund@FRONTIER.COM>
Subject: Re: Read text file with missing values
In-Reply-To: <201011222053.oAMHnjbZ003414@willow.cc.uga.edu>
Content-Type: text/plain; charset="utf-8"
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Sophia Tong
> Sent: Monday, November 22, 2010 12:54 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Read text file with missing values
>
> Dear listers,
>
> I have trouble to read data with more than 1 missing value for each
> record,
> and the data column got shifted. Any way to fix it?
> Here is my sample data and program.
>
> 369 0 0 AG CC CT TT TT CT GG TT NC GG GG
> 370 0 0 GG CC CT CC TT CT GG TT NC GG GG
> 380 61 0 GG CC CC TT TT CC AG CT NC GG GG
> 385 1 69 0 AG CT TT CC TT CT GG CT NC GG GG
> 386 74 1 AG CT CT CT TT CT GG TT NC GG GG
> 388 1 63 0 GG CT NC CC TT CC GG CT NC GG GG
>
> data uc.UC;
> %let _EFIERR_ = 0;
> infile 'C:\Documents and Settings\Project.txt'
> delimiter = ' ' MISSOVER DSD lrecl=32767 firstobs=1 ;
> input ID Affection Age Male SNP1$ SNP2$ SNP3$ SNP4$ SNP5$ SNPP6$ SNP7$
> SNP8$ SNP9$ SNP10$ SNP11$;
> if _ERROR_ then call symput('_EFIERR_',1);
> run;
>
> Thanks in advance.
>
> Sophia
Sophia,
There is no general solution for your problem in this case. The problem is that you are using a single blank for a missing value, so there is no convenient way to differentiate between a blank that is a missing value and a blank that is a delimiter. In addition, you can't use fixed column input because missing ages (2-column wide values) are being replaced by a single blank (messing up which columns the data values are in). I would get the data fixed upstream, to either use something other than a blank for the delimiter, or use something other than blank as the missing value, or make sure each variable value begins in the same column across records.
Hope this is helpful,
Dan
Daniel Nordlund
Bothell, WA USA
|