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; format DateIn DateOut mmddyy8.; /*#4*/ run;
1 | Create a new variable named Days and calculate how many days each patient was hospitalized. Since DateIn and DateOut are numeric variables, you can simply subtract to find the difference. However, the dates should be inclusive because patients are charged for both the first and last days. Therefore, you must add 1 to the difference. |
2 | Create a new variable named RoomCharge by multiplying the number of Days by the RoomRate value. |
3 | To calculate the total cost for each patient, create a variable named Total whose value is the sum of RoomCharge and EquipCost. |
4 | Use the FORMAT statement to associate the format MMDDYY8. to the DateIn and DateOut variable. |
3.15.221.133