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 (May 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 20 May 2010 11:05:47 -0400
Reply-To:     Joe Whitehurst <joewhitehurst@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Whitehurst <joewhitehurst@GMAIL.COM>
Subject:      Re: How to delete observations with all variables missing?
Comments: To: Yuewei Liu <elek.liu@gmail.com>
In-Reply-To:  <AANLkTilv038pPRkMRMGROnBS722QKatyI2Q7V5rn1gh9@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Of course, it you wanted the data in a SAS dataset, you would still have to define the variables. But you could avoid defining the variables for records with all missing values.

data test; infile test input; if ^missing(_infile_) then input /* variable specifications*/; run;

On Thu, May 20, 2010 at 10:58 AM, Joe Whitehurst <joewhitehurst@gmail.com>wrote:

> You can still avoid moving the data into the PDV like this: > > filename test 'e:\weblog_analysis\test.txt'; > 2 > 3 data test; > 4 infile test; > 5 input; > 6 if ^missing(_infile_); > 7 run; > > NOTE: The infile TEST is: > Filename=e:\weblog_analysis\test.txt, > RECFM=V,LRECL=256,File Size (bytes)=85, > Last Modified=20May2010:10:52:08, > Create Time=20May2010:10:52:08 > > NOTE: 5 records were read from the infile TEST. > The minimum record length was 0. > The maximum record length was 26. > NOTE: The data set WORK.TEST has 3 observations and 0 variables. > NOTE: DATA statement used (Total process time): > real time 0.03 seconds > cpu time 0.03 seconds > > Test.txt is a text file with 5 records with two them having all missing > data. > > > On Thu, May 20, 2010 at 8:36 AM, Yuewei Liu <elek.liu@gmail.com> wrote: > >> The question is, we often got some raw data set with missing observations >> for all variables. So we have to do this. Anyway, I think the coalesce and >> coalescec functions are nice to handle this. >> Thank you for your reply. >> >> Yuewei >> >> >> On Thu, May 20, 2010 at 8:12 PM, Joe Whitehurst <joewhitehurst@gmail.com>wrote: >> >>> I'm curious. Wouldn't it be move efficient to put either of these >>> functions in a where clause to prevent observations with all missing values >>> for being loaded into the PDV at all? >>> >>> >>> On Thu, May 20, 2010 at 7:06 AM, Yuewei Liu <elek.liu@gmail.com> wrote: >>> >>>> Data _null_, very cool... Thank you very much. >>>> >>>> Yuewei >>>> >>>> On Thu, May 20, 2010 at 6:21 PM, Data _null_; <iebupdte@gmail.com> >>>> wrote: >>>> >>>> > if missing(cats(of _all_)) then delete; >>>> > You will need the system option MISSING=' '; >>>> > >>>> > or >>>> > >>>> > if missing(coalesce(of _numeric_)) >>>> > and missing(coalesceC(of _character_)) then delete; >>>> > >>>> > On 5/20/10, Yuewei Liu <elek.liu@gmail.com> wrote: >>>> > > Hi all. How to delete the observation, if all values of all the >>>> variables >>>> > > are missing? I did it using the Array statements. Do you have some >>>> better >>>> > > ideas? >>>> > > Any suggestions are appreciated. >>>> > > >>>> > > data have; >>>> > > input x y; >>>> > > length z $ 8; >>>> > > z=ifc(y=.," ",strip(put(y,best.))); >>>> > > cards; >>>> > > 1 2 >>>> > > 3 1 >>>> > > 4 2 >>>> > > 3 . >>>> > > 3 3 >>>> > > . 2 >>>> > > . . >>>> > > 3 . >>>> > > . . >>>> > > . 2 >>>> > > . . >>>> > > ; >>>> > > data want(drop=tag i j); >>>> > > set have; >>>> > > array num [*] _numeric_; >>>> > > array char[*] _character_; >>>> > > tag=0; >>>> > > do i=1 to dim(num); >>>> > > if num[i]^=. then do; >>>> > > tag=1; >>>> > > return; >>>> > > end; >>>> > > end; >>>> > > do j=1 to dim(char); >>>> > > if char[j]^=" " then do; >>>> > > tag=1; >>>> > > return; >>>> > > end; >>>> > > end; >>>> > > if tag=1; >>>> > > run; >>>> > > >>>> > > Yuewei >>>> > > >>>> > >>>> >>> >>> >> >


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