|
Yet another solution using 'do until' trick which i learned from SAS-L....
data practice_dates;
input id date mmddyy8. test passed $;
format date mmddyy10.;
datalines;
1234 01021969 2345 Y
1234 01301969 3456 N
3157 02031969 2345 N
3157 02201969 2897 N
3157 04151969 2345 Y
1011 02051969 2345 N
1011 02211969 2345 N
1011 05201969 2897 N
2468 03211969 2234 Y
2468 07151969 2255 Y
;
run ;
proc sort;by id ;
data final (where = ( new in (1,2) ) drop=yes no ) ;
do until (last.id) ;
set practice_dates ;
by id ;
select(passed);
when('Y') yes=1;
when('N') no=1;
otherwise;
end ;
end ;
if yes and no then new=1 ;
else if yes then new=2 ;
else if no then new=3 ;
do until (last.id) ;
set practice_dates ;
by id ;
output ;
end ;
run ;
proc print data=final(drop= new );
run ;
On Fri, 16 May 2008 10:53:45 -0700, geraden72011 <geraden72011@GMAIL.COM>
wrote:
>I have the following example i created:
>
>data practice_dates;
>input id date mmddyy8. test passed $;
>format date mmddyy10.;
>datalines;
>1234 01021969 2345 Y
>1234 01301969 3456 N
>3157 02031969 2345 N
>3157 02201969 2897 N
>3157 04151969 2345 Y
>1011 02051969 2345 N
>1011 02211969 2345 N
>1011 05201969 2897 N
>2468 03211969 2234 Y
>2468 07151969 2255 Y
>;
>proc sort data=practice_dates;
>by id date;
>run;
>
>What I want to do is to create a new datafile that has all of the
>records for the ID's that have a passed = 'Y' for any of the tests.
>
>so for the above example my new datafile would have all of the
>following
>
>1234 01021969 2345 Y
>1234 01301969 3456 N
>3157 02031969 2345 N
>3157 02201969 2897 N
>3157 04151969 2345 Y
>2468 03211969 2234 Y
>2468 07151969 2255 Y
>
>any help is greatly appreciated.
|