Example: Using Dates and Times in Calculations

Suppose you work in the billing department of a small community hospital. In this example, you create a new SAS data set from the input data file that is referenced by the fileref Aprbills. A portion of the data file below shows the following patient data:
  • last name
  • date checked in
  • date checked out
  • daily room rate
  • equipment cost
Output 13.4 Unformatted Cert.AprBills Data Set
Cert.AprBills Data Set
data work.aprhospitalbills;
  set cert.aprbills;
  Days=dateout-datein+1;                  /*#1*/
  RoomCharge=days*roomrate;               /*#2*/
  Total=roomcharge+equipcost;             /*#3*/ run; proc print data=work.aprhospitalbills; ...

Get SAS Certified Specialist Prep Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.