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 (May 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 16 May 2008 14:15:53 -0400
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: question about creating a data subset
Comments: To: geraden72011@GMAIL.COM

A data step approach entails a bit more than the sql approach but, if you're not comfortable with sql, one solution would be:

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 descending passed; run;

data want (drop=passed_test); set practice_dates; retain passed_test; by id; if first.id then do; if passed eq 'Y' then passed_test=1; else passed_test=0; end; if passed_test then output; run;

HTH, Art -------- 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.


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