Scenario 5

Directions

Open the ehs01 program from the EHS folder and correct the errors in the program. For instructions, see the commented code in the program that is marked by a slash (/) and an asterisk (*).
Example Code 17.1 ehs01 Program: Fix the Errors
data work.aprilbills drop=Total, EquipCost;                /*#1*/
   set cert.aprbills;
   if Days > 7 then Discount=(RoomCharge)*20% else 0;      /*#2*/
   TotalDue=Total-Discount;                                /*#3*/
   format DateIn DateOut date9;                            /*#4*/
   format RoomRate RoomCharge Discount TotalDue dollar10.; /*#5*/
proc print data=work.aprilbills;                           /*#6*/
Here are instructions that are commented in the program, ehs01.
1 Drop the variables Total and EquipCost.
2 If the Days variable is greater than 7, then Discount is the value of RoomCharge multiplied by 20 %. If the Days variable is less than or equal to 7, then Discount is set to 0.
3 Create a new variable, TotalDue, with a value of Total minus Discount.
4 Format DateIn and DateOut to appear as 05APR2009.
5 Format the variables RoomRate, RoomCharge, Discount, and TotalDue to appear as $100.00.
6 Print your results.

Test Your Code

  1. What is the value of the variable TotalDue in observation 4?
  2. What is the value of the variable Discount in observation 5?

Objectives Accomplished

  • Identify the characteristics of SAS statements.
  • Define SAS syntax rules and identify syntax errors such as misspelled keywords, unmatched quotation marks, missing semicolons, and invalid options.
  • Use the log to help diagnose syntax errors in a given program.
Last updated: February 14, 2019
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset