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 (February 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 3 Feb 2004 12:00:23 -0500
Reply-To:     Eric <eoyount@WARMMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Eric <eoyount@WARMMAIL.COM>
Organization: heat email address to reply
Subject:      Re: IF/Then problem
Content-Type: text/plain; charset=us-ascii

All you need is an else in front of your second if statement as well. Like so:

if f1=0 and f2=1 then output zeroone; else if f1=1 and f2 =0 then output onezero; else output rest;

Hope this helps, Eric

On 3 Feb 2004 08:37:19 -0800, ms7942@albany.edu (siddiqui) wrote:

>Hi, >Wondering whats the solution to this problem >Objective: > >To output three data sets containing the following values >Onezero[1 0] >Zeroone[0 1] >Rest > >Program: > >options nocenter formdlim='-'; >data albany ; >input f1 f2; >datalines; >0 1 >1 >0 >0 0 >1 1 >6 8 >123 0 >0 0 >0 1 >1 0 >1 28 >28 1 >; >run; > >data zeroone onezero rest; >set albany; > >if f1=0 and f2=1 then output zeroone; >if f1=1 and f2 =0 then output onezero; >else output rest; >run; >proc print data=zeroone; >run; >proc print data=onezero ; >run; >proc print data= rest; >run; > >Output: > >Obs f1 f2 > > 1 0 1 > 2 0 1 > >---------------------------------------------------------------------------------------------------------------------------------------------------------------- > >Obs f1 f2 > > 1 1 0 > 2 1 0 > >---------------------------------------------------------------------------------------------------------------------------------------------------------------- > > >Obs f1 f2 > > 1 0 1 > 2 0 0 > 3 1 1 > 4 6 8 > 5 123 0 > 6 0 0 > 7 0 1 > 8 1 28 > 9 28 1 > >Problem: > >The else statement uses the 2nd if/then statement to assign values to >the dataset Rest


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