Date: Wed, 25 Jun 2008 07:58:31 -0400
Reply-To: Arthur Tabachneck <art297@NETSCAPE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Arthur Tabachneck <art297@NETSCAPE.NET>
Subject: Re: recoding variables with missing values
Kristoffer,
Couldn't you just muliply the two values? For example:
data want;
input aa708d aa666d;
extra=aa708d*aa666d;
cards;
0 .
. 1
0 1
0 0
. 0
1 1
;
HTH,
Art
----------
On Wed, 25 Jun 2008 04:34:32 -0700, k <kristoffer.backman@GMAIL.COM> wrote:
>Hi.
>
>I have a question regarding the recoding of variables with missing
>values. I have a dateset consisting of a two variables both taking the
>value one or zero. I then want to create a third variable that takes
>the value one if both of the original variables have the value one. If
>one or both of the original variables take the value zero then the new
>variable takes the value zero and if one of the original variables
>have a missing value I want the new variables to be a missing value. I
>use this code to achieve this and it does the trick:
>
>if aa708d=. and aa666d=. then extra=.;
>if aa708d=. and aa666d=0 then extra=.;
>if aa708d=0 and aa666d=. then extra=.;
>if aa708d=1 and aa666d=. then extra=.;
>if aa708d=. and aa666d=1 then extra=.;
>if aa708d=0 and aa666d=0 then extra=0;
>if aa708d=1 and aa666d=1 then extra=1;
>if aa708d=1 and aa666d=0 then extra=0;
>if aa708d=0 and aa666d=1 then extra=0;
>
>The question then is. Is there an easier way of doing this. This is
>the code I used first:
>
>if aa708d=1 and aa666d=1 then extra=1; else extrafet=0;
>
>but this code produce zeros for the new variable where there should be
>missing values. The problem seems to lie with the way sas handles
>missing values. Is there a smart way to avoid or go around this
>problem and make the recoding easier?
>
>Regards
>
>Kristoffer
|