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 (February 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 27 Feb 2007 17:22:36 -0500
Reply-To:     Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject:      Re: RECODE MISSING
In-Reply-To:  <200702272036.l1RKCiA5023948@mailgw.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

This is a direct approach and should certainly work. There's a theoretical disadvantage in terms of efficiency in that the variable-name test is being done for every record and every variable. If the number of variables and records is not too big, this is probably not a significant practical problem.

A way to avoid that would be to use two SELECT INTO statements in PROC SQL to query the dictionary tables and construct two macro variables: one containing a list of all numeric variables beginning with A_, and a second containing all character variables beginning with A_. The macro variables could then be used in the ARRAY statements, replacing the _NUMERIC_ and _CHARACTER_ lists.

Mike Rhoads Westat RhoadsM1@Westat.com

-----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Ya Huang Sent: Tuesday, February 27, 2007 3:37 PM To: SAS-L@LISTSERV.UGA.EDU; Ran S Cc: Ya Huang Subject: Re: RECODE MISSING

/* recode the numeric variables */ DO inum = 1 to dim(num_array); if upcase(substr(vname(num_array(inum)),1,2))='A_' and num_array{inum} IN (.,98) then num_array{inum}=998; END;

/* recode the character variables */ Do ichar = 1 to dim(char_array); if upcase(substr(vname(char_array(ichar)),1,2))='A_' and char_array{ichar} IN ("98",".") then char_array {ichar}="998"; END;

On Tue, 27 Feb 2007 15:27:55 -0500, Ran S <raan67@YAHOO.COM> wrote:

>Thanks. Lookslike it works for numeric variables. I have a combination of >variables numeric and character and I am using following the code to recode: > >ARRAY num_array{*} _NUMERIC_; > ARRAY char_array{*} _CHARACTER_; > > /* recode the numeric variables */ > DO inum = 1 to dim(num_array); > if num_array{inum} IN (.,98) then num_array{inum}=998; > END; > > /* recode the character variables */ > Do ichar = 1 to dim(char_array); > if char_array{ichar} IN ("98",".") then char_array >{ichar}="998"; > END; > > drop inum ichar; > >But Now I want to recode only A_ variables. > >Thanks! Ran


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