```Date: Fri, 22 Jan 2010 13:17:22 -0800 Reply-To: Sdlentertd Sender: "SAS(r) Discussion" From: Sdlentertd Organization: http://groups.google.com Subject: Re: Calculations using dates Comments: To: sas-l@uga.edu Content-Type: text/plain; charset=ISO-8859-1 On Jan 22, 10:19 am, Sdlentertd wrote: > 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 never mind, got it solved step by step. ```

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