
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 Code1 ehs01 Program : Fix the Errors
data work.aprilbills drop=Total, EquipCost;
set cort.aprbills;
if Days > 7 then Discount=(RoomCharge) * 20% else 0;
TotalDue=Total - Discount;
format DateIn DateOut date9;
format RoomRate RoomCharge Discount TotalDue dollar10.;
proc print data=work.aprilbills.

Here are instructions that are commented in the program, ehs01.
- Drop the variables Total and EquipCost.
- 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.
- Create a new variable, TotalDue, with a value of Total minus Discount.
- Format DateIn and DateOut to appear as 05APR2009.
- Format the variables RoomRate, RoomCharge, Discount, and TotalDue to appear as $100.00.
- Print your results.
[사용 코드]
libname cert 'C:/folders/mypath/cert/';
data work.aprilbills (drop=total equipcost);
set cert.aprbills;
if days > 7 then discount=(roomcharge)*0.2; else discount=0;
totaldue = total-discount;
format datein dateout date9.;
format roomrate roomcharge discount totaldue dollar10.2;
run;
proc print data=work.aprilbills;
run;
- DROP = data set option 은 ( ) 안에서 사용 !!
- datew. / dollarw.d 사용법 정확히 파악하기 !!

DOLLARw.d Format

DATEw. Format


'SAS > Scenario' 카테고리의 다른 글
| Scenario 7 (0) | 2022.12.25 |
|---|---|
| Scenario 6 (0) | 2022.12.25 |
| Scenario 4 (0) | 2022.12.25 |
| Scenario 3 (0) | 2022.12.25 |
| Scenario 2 (0) | 2022.12.25 |