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 (October 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 6 Oct 2009 14:33:49 -0400
Reply-To:     Rieza Soelaeman <rsoelaeman@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Rieza Soelaeman <rsoelaeman@GMAIL.COM>
Subject:      Doing arithmetical operations on observations that meet certain
              conditions for records w/ multiple observations to a unique
              identifier...
Content-Type: text/plain; charset=ISO-8859-1

Dear all, Supposing I have data as follows: personid specimen_type coll_dt count 001 A 1/1/2009 1 001 B 4/4/2009 2 001 C 4/4/2009 3 002 A 3/6/2009 1 002 B 6/21/2009 2 003 D 5/9/2009 1 003 A 5/30/2009 2 003 B 7/14/2009 3

I want to have SAS create a variable "testlag" that subtracts the coll_dt (where specimen_type = B) from the coll_dt (where specimen_type=A). I envision the final dataset to be something like this: personid specimen_type coll_dt count testlag 001 A 1/1/2009 1 93 001 B 4/4/2009 2 001 C 4/4/2009 3 002 A 3/6/2009 1 107 002 B 6/21/2009 2 003 D 5/9/2009 1 003 A 5/30/2009 2 45 003 B 7/14/2009 3

Is it possible to do this directly using this "long" format data or would I need to convert the data to wide first (using proc transpose or arrays), and then subtract colldt1 from colldt 2.

Specifically, can I do testlag = coll_dt (where specimen_type = 'B' and count = 2) - coll_dt (where specimen_type=A and count = 1);, or, like I said above, will I need to make it wide and do "testlag = colldt2 - colldt 1;"?

Thanks, Rieza

-- RHS


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