SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Date and Time Values
Using Dates and Times in Calculations


The value for RoomCharge is calculated next. RoomCharge is the product of Days and RoomRate.
     options yearcutoff=1920;
     data perm.aprbills;
        infile aprdata;
        input lastname $8. @10 DateIn mmddyy8. +1 DateOut
           mmddyy8. +1 RoomRate 6. @35 equipcost 6.;
        Days=dateout-datein+1;
        RoomCharge=days*roomrate;
        Total=roomcharge+equipcost;
     run;

Raw Data File Aprdata
1---+----10---+----20---+----30---+----40
Akron    04/05/99 04/09/99 175.00 298.45
Brown    04/12/99 05/01/99 125.00 326.78
Carnes   04/27/99 04/29/99 125.00 174.24
Denison  04/11/99 04/12/99 175.00  87.41
Fields   04/15/99 04/22/99 175.00 378.96
Jamison  04/16/99 04/23/99 125.00 346.28 


Program Data Vector

The value for Total is the final calculation. Total is the sum of EquipCost and RoomCharge.
     options yearcutoff=1920;
     data perm.aprbills;
        infile aprdata;
        input LastName $8. @10 DateIn mmddyy8. +1 DateOut
           mmddyy8. +1 RoomRate 6. @35 EquipCost 6.;
        Days=dateout-datein+1;
        RoomCharge=days*roomrate;
        Total=roomcharge+equipcost;
     run;

Raw Data File Aprdata
1---+----10---+----20---+----30---+----40
Akron    04/05/99 04/09/99 175.00 298.45
Brown    04/12/99 05/01/99 125.00 326.78
Carnes   04/27/99 04/29/99 125.00 174.24
Denison  04/11/99 04/12/99 175.00  87.41
Fields   04/15/99 04/22/99 175.00 378.96
Jamison  04/16/99 04/23/99 125.00 346.28 


Program Data Vector


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement