Date: Wed, 14 Oct 2009 08:50:06 -0700
Reply-To: SAS_learner <proccontents@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: SAS_learner <proccontents@GMAIL.COM>
Subject: Re: If then else logic Not working
In-Reply-To: <48ec11ce-eff4-4bc4-914d-c7178521e242@k13g2000prh.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Thank you all for explanation, I understand what mistake I was doing , Thank
you all for your time and help
SL
On Tue, Oct 13, 2009 at 2:47 AM, such <such.jain@gmail.com> wrote:
> Hello,
>
> Patrick is correct that you have to reprogram your if else condition
> because third condition will never be selected. Following code might
> help.
>
> Data test ;
> set test ;
> if Case2= 3 Then do;
> if case = 1 then do;
> if Case1 = 2 then Misswk33 = 'N';
> else Misswk33 = 'Y';
> end;
> else Misswk33 = 'N';
> end;
> Run;
>
> The above code will help you to get desirable results.
>
> Regards,
>
> Such
>
> On Oct 13, 11:21 am, procconte...@GMAIL.COM (SAS_learner) wrote:
> > hello guys ,
> >
> > my conditions are
> >
> > If Case =1 and case1 = 2 and case3 = 3 then Misswk33 = N
> >
> > Else If Case =1 and case3 = 3 then Misswk33 =Y
> >
> > Else If Case2 = 3 Then Misswk33 = N ;
> >
> > But some Misswk33 is not properly populated
> >
> > Data test ;
> > Input Usubjid $4. case case1 case2 ;
> > datalines ;
> > 1001 . . 3
> > 1001 . . 3
> > 1002 1 2 3
> > 1002 1 2 3
> > 1003 1 . .
> > 1004 1 . 3
> > 1004 1 . 3
> > ;
> > Run;
> >
> > Data test ;
> > set test ;
> > if (Case =1 ) and (Case1 = 2 ) and (Case2= 3) Then Misswk33 = 'N';
> > Else If (Case2= 3) Then Misswk33 = 'N';
> > Else if (Case =1 ) and (Case2= 3) Then Misswk33 = 'Y';
> > Run;
> >
> > /*Some how Misswk33 is getting value N only */;
>
|