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 (April 2012, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 16 Apr 2012 11:33:09 -0500
Reply-To:     "Data _null_;" <iebupdte@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Data _null_;" <iebupdte@GMAIL.COM>
Subject:      Re: How to change many missing variables to 0 in a single data
              step
Comments: To: "Choate, Paul@DDS" <Paul.Choate@dds.ca.gov>
In-Reply-To:  <9529D0E21F68E547B2D948785925A67E15A7843C9F@MDTSSWECCR18.rf01.itservices.ca.gov>
Content-Type: text/plain; charset=ISO-8859-1

Wasn't Toby was referring to Soren's Macro solution of code gening an if statement for each variable.

On 4/16/12, Choate, Paul@DDS <Paul.Choate@dds.ca.gov> wrote: > FYI - The list keyword _NUMERIC_ accesses all the numeric values in the PDV. > > Paul Choate > DDS Data Extraction > (916) 654-2160 > -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of toby > dunn > Sent: Monday, April 16, 2012 8:54 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: How to change many missing variables to 0 in a single data step > > Works great if your variable names are VarA1 - VarA50... > > Not so great once you have to use it on real data where the names arent > standardized... YOu will either have to hand type them in a list or use > another macro to retrieve the variable names. The array method doesn't need > you to find or explicitly write them out. > > Toby Dunn > > > If you get thrown from a horse, you have to get up and get back on, unless > you landed on a cactus; then you have to roll around and scream in pain. > > "Any idiot can face a crisis-it's day to day living that wears you out" > ~ Anton Chekhov > > > >> Date: Mon, 16 Apr 2012 02:00:17 -0400 >> From: s.lassen@POST.TELE.DK >> Subject: Re: How to change many missing variables to 0 in a single data >> step >> To: SAS-L@LISTSERV.UGA.EDU >> >> Randy, >> You can solve this with an array - but as you state that you have a large >> number of rows in your table, a macro is probably more efficient, e.g.: >> >> %macro miss2zero; >> %local i; >> %do i=1 %to 50; >> if VarA&i=. then VarA&i=0; >> %end; >> %mend; >> >> data want; >> set have; >> %miss2zero; >> run; >> >> I tested this approach against the array solution, and it ran in half the >> time, and with half the CPU usage. >> >> Regards, >> Søren >> >> >> On Sun, 15 Apr 2012 10:02:36 -0400, Randy <RANDISTAN69@HOTMAIL.COM> wrote: >> >> >I have many variables and some of the values are missing. I want to >> >change the missing values to 0 in a single data step. >> > >> >The code I have written is: >> >Data want ; set have; >> >if VarA1 - VarA50 = . then VarA1 - VarA50 = 0 ; >> >run; >> > >> >I am getting an error term. What is the mistake that I am making? >> > >> > Randy >


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