Date: Tue, 3 Feb 2004 08:52:08 -0800 "Choate, Paul@DDS" "SAS(r) Discussion" "Choate, Paul@DDS" Re: IF/Then problem To: siddiqui

Siddiqui -

All three statements need to cascade in your if-then-else statements, not just the last two.

data zeroone onezero rest; set albany;

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

hth

Paul Choate DDS Data Extraction (916) 654-2160

-----Original Message----- From: siddiqui [mailto:ms7942@ALBANY.EDU] Sent: Tuesday, February 03, 2004 8:37 AM To: SAS-L@LISTSERV.UGA.EDU Subject: IF/Then problem

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