SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Date and Time Values
Using Dates and Times in Calculations


Follow the execution of the program you've written. When the DATA step executes, the values for DateIn and DateOut are converted to SAS date values.
     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

After the rest of the INPUT statement executes, the value for Days is created by subtracting the SAS date value for DateIn from the value for DateOut and then adding 1.
     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;

Program Data Vector


back||next


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

Terms of Use & Legal Information | Privacy Statement