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 (April 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 26 Apr 2007 11:49:45 -0400
Reply-To:     Jack Clark <JClark@CHPDM.UMBC.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jack Clark <JClark@CHPDM.UMBC.EDU>
Subject:      Re: A SORT ( SEQUENCE) PROBLEM
Comments: To: Rathindronath <mehedisas@YAHOO.COM>
In-Reply-To:  A<200704261536.l3QAkHCK020138@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"

Rath,

I created a sequence variable (SEQVAR) by scanning for the second "word" in the VISITS field. This returns a blank when the value is 'Screening' and the day number when present. A sort can then be done on Subject, Seqvar and descending status to generate the desired output.

data have; input @01 subject $3. @10 visit $10. @25 status $2. ; seqvar = scan(visit,2,' '); cards; 001 day 1 pr 001 day 1 po 001 day 2 pr 001 day 2 po 001 Screening pr 001 Screening po 002 Screening po 002 Screening pr 002 day 1 pr 002 day 1 po 002 day 2 pr 002 day 2 po run;

proc sort data = have out = need (drop=seqvar); by subject seqvar descending status; run;

proc print data = need; run;

Jack Clark Research Analyst Center for Health Program Development and Management University of Maryland, Baltimore County

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Rathindronath Sent: Thursday, April 26, 2007 11:36 AM To: SAS-L@LISTSERV.UGA.EDU Subject: A SORT ( SEQUENCE) PROBLEM

I have a following dataset:

subject visit status ------- ----- ------

001 day 1 pr 001 day 1 po 001 day 2 pr 001 day 2 po 001 Screening pr 001 Screening po 002 Screening po 002 Screening pr 002 day 1 pr 002 day 1 po 002 day 2 pr 002 day 2 po

Need to sort or need to use sequence to produce the sorted result:

subject visit status ------- ----- ------

001 Screening pr 001 Screening po 001 day 1 pr 001 day 1 po 001 day 2 pr 001 day 2 po 002 Screening pr 002 Screening po 002 day 1 pr 002 day 1 po 002 day 2 pr 002 day 2 po

Thanks you


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