LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2010, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 22 Nov 2010 11:04:33 -0500
Reply-To:     Nat Wooding <nathani@VERIZON.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Nat Wooding <nathani@VERIZON.NET>
Subject:      Re: Better way to handle MISSING test
In-Reply-To:  <AANLkTimFHc72GUWDhSmSh_nxuy82=K82R-nQtmtivEz7@mail.gmail.com>
Content-Type: text/plain; charset="US-ASCII"

This can be simplified a bit if

1) there are few other numeric variables in the data set and 2) there are no other numeric variables that should not have zeros substituted for missing values.

Nat Wooding

Data test; input a b c; cards; 1 . 2 3 4 . ;

Data Lizette; set test; array vars_check _numeric_ ; do __t = 1 to dim(vars_check); vars_check[__t] = coalesce(vars_check[__t],0); end; run;

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Joe Matise Sent: Monday, November 22, 2010 10:51 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Better way to handle MISSING test

DAYS1=COALESCE(DAYS1,0);

will do the same thing (COALESCE = choose the first non-missing argument). I don't think there's a way to do it multiple times at once, although you can use an array:

array vars_check days1-days5 space1-space5 tapes volumes; do __t = 1 to dim(vars_check); vars_check[__t] = coalesce(vars_check[__t],0); end;

-Joe

On Mon, Nov 22, 2010 at 9:42 AM, Lizette Koehler <starsoul@mindspring.com>wrote:

> I have a series of vars that I am testing for MISSING. And if they are, > then set them to zero. > > IF MISSING(DAYS1) THEN DAYS1 = 0 ; > IF MISSING(DAYS2) THEN DAYS2 = 0 ; > IF MISSING(DAYS3) THEN DAYS3 = 0 ; > IF MISSING(DAYS4) THEN DAYS4 = 0 ; > IF MISSING(DAYS5) THEN DAYS5 = 0 ; > > IF MISSING(SPACE1) THEN SPACE1 = 0 ; > IF MISSING(SPACE2) THEN SPACE2 = 0 ; > IF MISSING(SPACE3) THEN SPACE3 = 0 ; > IF MISSING(SPACE4) THEN SPACE4 = 0 ; > IF MISSING(SPACE5) THEN SPACE5 = 0 ; > IF MISSING(TAPES) THEN TAPES = 0 ; > IF MISSING(VOLUMES) THEN VOLUMES = 0 ; > > > Is there a better way to do this, or is this the only way? > > Lizette >


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