Вы находитесь на странице: 1из 4

HOMEWORK ASSIGNMENT 1

SAS PROGRAMMING
Due: 2:30 PM, Thursday, September 17
See instructions for homework in Brightspace. You are to print out and hand in
the SAS program and the SAS output. You are also to submit the SAS programs in
Brightspace.
Remember, SAS datasets should be in the work library or a SAS library named
SASHW. So for the first part, the data set name should be Gradebook or
SASHW.Gradebook. There should be no variables created that are not
mentioned in the instructions.
PART 1
In this part, we will use the file Gradebook.xlsx which is in Brightspace. Of
course, grade calculation can be done in Excel. The point here is to use our SAS
skills. In each numbered section of this part, the name of the data set should be
Gradebook. You will write three SAS programs and hand in the SAS output of
each of these programs.
Note: This is not an actual gradebook nor does it have grades from any of my
classes.
1. Write a SAS program using the import procedure to create the SAS data file
Gradebook. Show the data set using the print procedure.
2. Write another SAS program using the data set from #1. There are no
variable names or labels in the Excel file. Create the variable names using a
data step. In order, the variable names should be ID, T1, T2, T3, T4 and
Final. Respectively, except for Final, create the labels Student ID, Test 1,
Test 2, Test 3, and Test 4. In the LABEL statement in the DATA step, use
the original variable names.
Hint: Look at the variable names in the SAS data set for # 1.

Use the print procedure twice in the SAS program, first showing variable
names and then showing the labels as column headers in the data sets.
3. Next, write another program for this part. Remember, the SAS data set has
already been created, the variables renamed, and the labels for the variables
given.
Each test is worth 18% of the course grade and the final is 28%. The final
can be used to replace the lowest test score, if it is higher than the lowest test
score.
a. First, create a variable called TSum. Since the lowest test grade is
allowed to be replaced by the final, if it is to the students advantage, then
TSum is the sum of the 4 out of 5 highest grades.
b. Next, calculate the weighted average for the course. Call this variable
Avg. Since each test is worth 18%, the weighted average will be the sum
of 18% of TSum and 28% of the grade on the final.
c. For the last variable, give a grade for the course as described below.
A: 89.50 100.0
B: 79.50 89.49
C: 69.50 79.49
F: < 69.50
The name of this variable is Grade.
d. Respectively, the labels are Test Sum, Average, and Grade. These labels
should be created in the DATA step.
Use the Print procedure to show the values for the tests, final, test sum,
average, and grades. The column headings should be the labels that you
created for the SAS data set. You are not to create any new variables that
have not been mentioned.

Part 2.
In this part, we will use the file Sales.txt. Be sure to look at the data file.
In this example, we have date, name of the sales person, city where sales
were made, and the amount sold that day. If no city is listed, that means the
sales person was making sales by telephone.
Write a single SAS program for this part. There should be one DATA step
and one procedure (PROC) step. Formatting should be done in the DATA
step. Labelling should be done as part of the PROC PRINT step. The title
of the SAS output should be Sales Report for Serena Moreno. The
observation numbers (Obs) should not be in the SAS output.
1. The name of the file is Sales. The variables are Date, Name, City, and
Amt. The variable Amt should have the label Daily Sales.
2. The date should be formatted to show the day, month, day of the month,
and year. For example, the first date would be Monday, August 3, 2015.
3. The SAS data set should only be for the observations or the variable
values for Serena Moreno.
4. Create a new variable TotComm that shows the cumulative commission
for each day of the week. The sales persons make a 7% commission on
sales. The label should be Total Commission.
5. Amt and TotComm should be formatted using only a single instance of
the format. Both variables should be formatted to show dollar signs and
two decimal places.

Вам также может понравиться