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 (October 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 18 Oct 2010 19:56:36 -0400
Reply-To:     Nat Wooding <nathani@VERIZON.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <nathani@VERIZON.NET>
Subject:      Re: reading NA as missing values without errors
In-Reply-To:  <AANLkTimfPQoNbGxG_+RfW5Y7cpMgMgrFyDX-FN03RrPD@mail.gmail.com>
Content-Type: text/plain; charset="US-ASCII"

Or, you can use the Captain Kirk approach and fix the input data:

data UnitedNations; infile datalines dsd dlm=" "; input @; _infile_ = tranwrd( _infile_ , 'NA' , '.' ); input test $ test2 test3 ; datalines; id1 3 6 id2 4 7 id3 NA 3 id4 NA NA id5 4 NA ;;;; run;

Thanks for the sample code, Joe

Nat Wooding -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Joe Matise Sent: Monday, October 18, 2010 2:21 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: reading NA as missing values without errors

There's always the error ignoring option.

input numfield ??;

ie:

data UnitedNations; infile datalines dsd dlm=" "; input test $ test2 ?? test3 ??; datalines; id1 3 6 id2 4 7 id3 NA 3 id4 NA NA id5 4 NA ;;;; run;

(Your http didn't pass through to me properly so I had to fake it).

-Joe

On Mon, Oct 18, 2010 at 12:51 PM, Arthur Tabachneck <art297@netscape.net>wrote:

> Michael, > > One alternative is to save the file, in R, as a dbf file and then > import the dbf file into SAS. An example is shown at: > http://www.r-bloggers.com/example-7-10-get-data-from-r-into-sas/ > > HTH, > Art > --------- > On Oct 18, 12:34 pm, Michael Friendly <frien...@yorku.ca> wrote: > > In R data files (.txt or .csv), missing is represented as 'NA'. In SAS, > > the missing statement allows only a set of single characters to > > be read and interpreted as missing values, without generating errors. > > > > For the following input step, there are lots of missing values in the > > numeric variables represented as NA. The data step below works, i.e., > > the missing NA values are correctly translated to SAS missing (.), but > > generates a great many errors. > > > > Perhaps there is some solution using PROC FORMAT and INVALUE formats, > > but I haven't found anything that applies in this case. > > > > title 'Missing data: UN example'; > > > > filename UN URL > > "http://socserv.socsci.mcmaster.ca/jfox/Books/Applied-Regression-2E/da.. > ."; > > data UnitedNations; > > infile UN dsd dlm=" " firstobs=2; > > input country $ region $ tfr contraception educationMale > > educationFemale lifeMale lifeFemale > > IMR GDP economicActivityMale economicActivityFemale > illiteracyMale > > illiteracyFemale; > > run; > > > > thanks, > > -Michael >


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