```Date: Sat, 23 Jan 2010 23:54:22 -0800 Reply-To: "Schwarz, Barry A" Sender: "SAS(r) Discussion" From: "Schwarz, Barry A" Subject: Re: Calculations using dates In-Reply-To: <2fa971d9-f6f9-47f6-b951-d16af40ca447@a6g2000yqm.googlegroups.com> Content-Type: text/plain; charset="us-ascii" If the quantity 60 is the supply for 30 days, shouldn't it be 2 per day, not .5 per day? -----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Sdlentertd Sent: Friday, January 22, 2010 9:19 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Calculations using dates Have this dataset DeathDT DatePurch DAYSUPPLY QTYPurch PriceUnit 12/02/2009 11/15/2009 30 60 1.00 I am trying to find a way to figure out how much money is lost due to death: if a person purchased 60units at \$1.00, but died after 16 days of taking that medication, we have 14 days left (need to calculated the days left) and need to figure out how much that 14 days is worth Need to do this in sas: if death is after datePurchased then do; Death date minus DatePurch = x; QTY / DAYSUPPLY =qtyPerDay; count how many days left after death until DatePurch+Daysupply (to figure out when the supply expires) = y; y (days left after death) * qtyPerDay = z; (QTY left after death) then z* PriceUnit to figure out the final \$ left on medicine after a person died. So in my example: 14 days after death, 0.5 medicine per day = 7qty * \$1.00 = \$7.00 loss Thank you ```

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