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 (February 2008, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 5 Feb 2008 07:41:08 -0800
Reply-To:     SAS-FU <lee.rozzelle@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SAS-FU <lee.rozzelle@GMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: Simply Cannot Input This Text File
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

On Feb 1, 5:04 pm, art...@NETSCAPE.NET (Arthur Tabachneck) wrote: > Lee, > > I have to wonder whether your problem is odd characters or simply that > you're not seeing what you expect to see. If it is the latter, possibly > the solution is to add format and informat statements for each of your > variables. > > Of course, you could take care of both, by using _infile_ and compress, as > suggested, but to only keep letters, numbers and underscores and/or other > wanted characters that you expect are in your data. > > Try something like: > > data aaa; > infile q dsd dlm='|' missover; > informat NM_TITLE $4.; > informat GIVEN_NM $25.; > informat SURNM $30.; > /* etc, etc. */ > format NM_TITLE $4.; > format GIVEN_NM $25.; > format SURNM $30.; > /* etc, etc. */ > > input @; > _infile_ = compress(_infile_,"kadf"); > > input > NM_TITLE $ GIVEN_NM $ SURNM $ NM_SUFX $ MP_NBR $ ADDR_TYPE_DESC $ > MP_CNTCT_ORG_NM $ ADDR_LN_1 $ > ADDR_LN_1 $ ADDR_LN_2 $ CITY_NM $ STATE_PRVNC_CD $ POSTL_CD $ > CNTRY_CD $ ISO_CNTRY_CD $ CellCode $ DF_Promo_Code $ LANG_CD $; > run; > > HTH, > Art > ------ > > > > > > On Fri, 1 Feb 2008 13:13:03 -0800, SAS-FU <lee.rozze...@GMAIL.COM> wrote: > >On Feb 1, 2:36 pm, gerhard.hellrie...@T-ONLINE.DE (Gerhard Hellriegel) > >wrote: > >> On Fri, 1 Feb 2008 12:08:36 -0800, SAS-FU <lee.rozze...@GMAIL.COM> > wrote: > >> >On Feb 1, 1:54 pm, tobyd...@HOTMAIL.COM (toby dunn) wrote: > >> >> Use the _Infile_ automatic variable and compress the unwanted > characters > > >> from the record before you read it into SAS. > > >> >> Toby Dunn > > >> >> "Don't bail. The best gold is at the bottom of barrels of crap." > >> >> Randy Pausch > > >> >> "Be prepared. Luck is where preparation meets opportunity." > >> >> Randy Pausch > > >> >> > Date: Fri, 1 Feb 2008 11:44:52 -0800 > >> >> > From: lee.rozze...@GMAIL.COM > >> >> > Subject: Simply Cannot Input This Text File > >> >> > To: SA...@LISTSERV.UGA.EDU > > >> >> > I have a pipe delimited text file that I am trying to read into > SAS. > >> >> > The problem is that the data isnt very clean, and in one of the > fields > >> >> > (Address), there will sometimes be acarriagereturncharacter > >> >> > imbedded within the field. The data reads in fine, then when it > hits > >> >> > a field with an imbeddedcarriagereturn, it stops reading. > > >> >> > So far, I have tried this: > > >> >> > data aaa; > >> >> > infile q dsd dlm='|' missover; > > >> >> > input > >> >> > NM_TITLE $ GIVEN_NM $ SURNM $ NM_SUFX $ MP_NBR $ ADDR_TYPE_DESC $ > >> >> > MP_CNTCT_ORG_NM $ @; > > >> >> > if find(ADDR_LN_1,'7F'x) then delete; > > >> >> > input > >> >> > ADDR_LN_1 $ ADDR_LN_2 $ CITY_NM $ STATE_PRVNC_CD $ POSTL_CD $ > CNTRY_CD > >> >> > $ ISO_CNTRY_CD $ > >> >> > CellCode $ DF_Promo_Code $ LANG_CD $; > > >> >> > run; > > >> >> > but this does not work. I thought that by using a trialing @, that > I > >> >> > could pause the input, check for thecarriagereturnhex value, then > >> >> > delete the record if it was found....but it doesnt work, SAS hits > the > >> >> >carriagereturnand stops reading.... > > >> >> > any help, or ideas are greatly appreciated. > > >> >> > Thanks. > > >> >> _________________________________________________________________ > >> >> Connect and share in new ways with Windows > > >> Live.http://www.windowslive.com/share.html? > > ocid=TXT_TAGHM_Wave2_sharelife_... > > > > >> Hide quoted text - > > >> >> - Show quoted text - > > >> >Im not familier with that, I will google it. Thank you very much. > > >> You're not familar with _infile_? That's quite easy: > > >> The INPUT statement filles a input-buffer. The input buffer is > available to > >> you in _INFILE_ > > >> Try that: > > >> data x; > >> infile "c:\data.dat"; > >> input; > >> put _infile_; > >> runN > > >> _infile_ is like a "normal" variable with some differences to that. E.g. > >> it's not occuring in the output dataset. > > >> You can use it to read the record and pick out and convert what you > want: > > >> example: > >> if _infile_=:"A" then id=substr(_infile_,5,11); > > >> or, like Toby wrote: > > >> string=compress(_infile_,"0D"x); -or whatever you want to clean out... > > >> Gerhard- Hide quoted text - > > >> - Show quoted text - > > >Thank you for all the replies but it is still n ot working. The > >character that is causing me the trouble is this : ..im assuming it > >is a carriage return, and that I should be representing it in SAS like > >this: "0D"x. I have also tried "07F"x, and nothing. > > >The code Im trying to use is as follows: > > >filename q 'U:\CIG\Optimization\Rozzelle\McQueary Issue > >\UVCM0802_INTLSPLITTERS_ARC_DM.txt'; > > >data aaa; > >infile q dsd dlm='|' missover; > > >input @; > >_infile_ = compress(_infile_,"0D"x); > > >input > >NM_TITLE $ GIVEN_NM $ SURNM $ NM_SUFX $ MP_NBR $ ADDR_TYPE_DESC $ > >MP_CNTCT_ORG_NM $ ADDR_LN_1 $ > >ADDR_LN_1 $ ADDR_LN_2 $ CITY_NM $ STATE_PRVNC_CD $ POSTL_CD $ CNTRY_CD > >$ ISO_CNTRY_CD $ > >CellCode $ DF_Promo_Code $ LANG_CD $; > > >run; > > >if anyone sees a problem, or has a suggestion, I would love to hear > >it...and thanks for taking a look at this.- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text -

FYI:

THIS was the solution that worked: Thanks Art. The "ignoredoseof" infile option takes care of any random carriage returns that may show up in my data.

data u.good; infile bad delimiter = '|' MISSOVER DSD lrecl=32767 ignoredoseof;

infile statement.......

run;


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