Date: Fri, 18 Jul 2008 13:32:30 -0400
Reply-To: sas biology <sasbio@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: sas biology <sasbio@GMAIL.COM>
Subject: a data manipulation question
Content-Type: text/plain; charset=ISO-8859-1
Hi All,
Can anyone help me solve the following problem?
I have the following data
*
data* test;
input subject visit flag1 ;
cards;
1 1 1
1 2 1
1 2 2
2 1 2
2 2 3
3 1 1
3 1 3
3 2 3
4 1 1
4 2 1
4 2 4
5 1 2
5 2 2
5 2 4
6 1 3
6 2 3
6 2 4
7 1 1
7 2 1
8 1 2
8 2 2
8 1 3
9 2 3
;
*
run*;
I need to process it using the following logic
**if flag1= 1 only then flag2 =1
else if flag1= 2 only then flag2= 2
else if flag1=3 only then flag2=3
else if flag1 in (1 2) then flag2=4
else if flag1 in (2 3) then flag2=5
else if flag1 in (1 3) then flag2=6
else if flag1 in (1 4) then flag2=7
else if flag1 in (2 4) then flag2=8
else if flag1 in (3 4) then flag2=9;
and my output data should look like this.
*
1* *1* *1* *4
1* *2* *1* *4
1* *2* *2* *4
2* *1* *2* *5
2* *2* *3* *5
3* *1* *1* *6
3* *1* *3* *6
3* *2* *3* *6
4* *1* *1* *7
4* *2* *1* *7
4* *2* *4* *7
5* *1* *2* *8
5* *2* *2* *8
5* *2* *4* *8
6* *1* *3* *9
6* *2* *3* *9
6* *2* *4* *9
7* *1* *1* *1
7* *2* *1* *1
8* *1* *2* *2* *
8* *2* *2* *2
8* *1* *3* *3
9* *2* *3* *3*
**
*Thanks in Advance.*
*SB
*