Date: Tue, 27 Feb 2007 16:11:13 -0600
Reply-To: Robin High <robinh@UNLSERVE.UNL.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Robin High <robinh@UNLSERVE.UNL.EDU>
Subject: Re: RECODE MISSING
In-Reply-To: <200702272000.l1RGGN0x023948@mailgw.cc.uga.edu>
Content-Type: TEXT/PLAIN; charset=US-ASCII
On Tue, 27 Feb 2007, Ran S wrote:
> Hi,
>
> I am using an array to recode universally all the variables with missing
> values (.) to 90. How can I just recode only those variables starting with
> prefix X_?
>
No compelling reason was given why you want to recode missing values of x_
to 90 and is almost never a good idea to do so; it is much safer to code
these missing values you want to be represented as '90' to one of the
other SAS missing data values, such as .z -- and then, if for some reason
you absolutely must see missing data as 90, you can assign .z to be 90 (or
some other code) with a FORMAT , e.g. something like:
proc format;
value ms .z='90';
run;
* can apply logic already given to identify
all variables that begin with x_ ;
DATA xyz;
do i=1 to 10;
x_ = 88+ CEIL(4*(RANUNI(929)));
IF x_ eq 90 then x_= .z;
OUTPUT;
END;
PROC freq; TABLE x_ FORMAT x_: ms. ; RUN;
The FREQ Procedure
Cumulative Cumulative
x_ Frequency Percent Frequency Percent
-------------------------------------------------------
89 2 33.33 2 33.33
92 4 66.67 6 100.00
Frequency Missing = 4 <--- 4 missing data values still there
.. and here they are coded as .z and represented as '90'
PROC PRINT NOobs; FORMAT x_: ms. ; RUN;
i x_
1 92
2 89
3 90
4 92
5 89
6 90
7 90
8 92
9 90
10 92
Robin High