CS计算机代考程序代写 database flex Stat 304 Introduction to SAS Programming

Stat 304 Introduction to SAS Programming
Assignment 8 Due on Monday, Nov 22

This assignment primarily reinforces techniques covered in the Lesson One to Seven, as some of you are preparing
your SAS BASE Certificate Exam. This assignment involves reading a fixed width data file and the techniques have not
been practiced in the previous assignments. You may need to explore some techniques using Google and/or SAS
Help and Document.

If you would like a text editor program that shows the column number of your cursor, you may download some free
tools such as NotePad ++ an/or Sublime, as we discussed in our lectures. You may also use your preferred text editor
as well.

• https://notepad-plus-plus.org/downloads/
• https://www.sublimetext.com/

1. Orion Star is in the process of acquiring Unicorn Athletics. We do not yet have access to the Unicorn database

but a file named Report.dat that contains the org. chart has been posted on D2L. The acquisition team suspects
that there may be some mid-level management positions at Unicorn that can be eliminated. They may want to
do additional analysis later but for now they have asked that you extract all Level 4 employees from the Report
file. The actual data starts on the third line of the file. The level values are in fixed positions as shown in the file
layout table below. After the level on each line of data is a string containing the job title and employee name.
You should open the file and become familiar with the data before trying to write your program.

Position Variable
1-8 Level 1
10-17 Level 2

19-26 Level 3
28-35 Level 4

37-44 Level 5
46-53 Level 6
??-100 Employee info

2. Create a data set from this file that contains the variables Level as a single digit numeric variable, along with

Job_Title and Employee_Name. I know several of you will be able to think of a simpler way to get to the results
than what is being required but the objective of this exercise is to give you some experience working with fixed
width raw data files that have no delimiters. Acceptable solutions to this exercise must have the following:

a. Two input statements with pointer controls.
b. A subsetting IF statement between the input statements.
c. No warnings or data errors in the log.
d. Only level 4 records in the output data set.

You will need to rely heavily on Reading Data into SAS Part 1 and 2 for this assignment. I recommend reviewing
from the end backwards because they demonstrated several things that don’t quite work before getting to the
way things need to be done. I also recommend reading in the employee info altogether as one variable then use
the functions of your choice to parse out the title and name. In order to read in the whole string you will need
to use the $char informat (syntax: $char12.) with the appropriate number depending on the length of your data.
Remember that length and informat/format are not the same thing especially for numeric variables. Length is
the number of bytes of storage (almost always 8) and informats specify the number of digits to be read.
Depending on how you set everything up, you may also want to look in SAS Help and Document for information
on the truncover option for the INFILE statement. Additional information about the truncover option can be
found at https://v8doc.sas.com/sashtml/lgref/z0146932.htm#z0166997. You will also use the SCAN function and

https://notepad-plus-plus.org/downloads/
https://www.sublimetext.com/
https://v8doc.sas.com/sashtml/lgref/z0146932.htm#z0166997

the SUBSTR function to extract the right information for Job_Title and Employee_Name. You will learn the two
functions again in Lesson 9 Writing Flexible Code with SAS Macro.

3. Use the CONTENT procedure to make sure the length of your variables matches the table below.

Also, in this step print a listing of your dataset which should match the output posted on D2L. You may want to
refer to the documentation in SAS Help and Document for more information on using BY and ID with the PRINT
procedure.

4. Print a FREQ report of all job titles that have Manager in the name. Order the output by the frequency.
5. In the previous assignments, you were required to create multiple observations from a single record (e.g. using

the OUTPUT statement in Assignment 5 Step 4). Often there is a need to go the other way and flatten out the
data to create a single row from multiple observations. This exercise has been designed to give you practice
creating one record from many while working with retain, arrays, and do loops. A dataset named Scores2012
has been posted on D2L. Flatten out the scoring data so there is one row per player. Use both Rank and Name
to group records together. We have duplicate ranks and even though there are no duplicate names, grouping by
both rank and name will help ensure uniqueness should we encounter duplicate names as well in future lists.
The successful solution must employ the following techniques:

a. Use an array named Made to store the number of each type of baskets made. The names of the
variables in the resulting data set will be automatically determined by the array itself.

b. The number of free throws goes in the first element of the array, two-pointers in the second element
and three-point field goals in the third.

c. Use a do loop to initialize all elements of the array to 0 on the first record of each group.
d. The output dataset must not contain the index variable from the do loop nor the two variables

score_type and baskets_made.
Hint: In order to generate the expected result, you will need to use the FIRST. and LAST. variables. The relevant
information can be found https://data-flair.training/blogs/variables-in-sas/. More information about the RETAIN
statement can be found on the Lesson 3 deck Slide 38.

6. Use a generic PRINT procedure to show the data in your new data set as shown in the output posted on D2L.
7. Paste your program code and log into a document that you save as PDF and submit to D2L. Your program must

contain an appropriate header.
8. Submit to D2L the ODS PDF file that contains the output of your procedures.

Good luck!

As a reminder: you need to submit your homework solution with TWO files:

• The 1st PDF — containing your SAS log (the primary grading), SAS source codes, and any other
supplementary answers that you wish to support your solution. Please keep the original font
formats/sizes of your SAS log and source codes. Before copying your Log window, make sure that you
close your SAS, then open the program, and rerun your entire SAS codes. In this way your Log window
will only contain logs relevant to your last submission.
• The 2nd PDF — Your SAS output. You should use the global ODS PDF option to save your outputs
locally for submission. More information about the ODS PDF option can be found at
https://docs.google.com/viewer?url=http%3A%2F%2Fsupport.sas.com%2Frnd%2Fbase%2Fods%2Fodspr
inter%2FPDF-tips.pdf

Your homework would NOT be graded if you didn’t follow the instruction above. And NO late submission
will be accepted.

https://data-flair.training/blogs/variables-in-sas/
https://docs.google.com/viewer?url=http%3A%2F%2Fsupport.sas.com%2Frnd%2Fbase%2Fods%2Fodsprinter%2FPDF-tips.pdf
https://docs.google.com/viewer?url=http%3A%2F%2Fsupport.sas.com%2Frnd%2Fbase%2Fods%2Fodsprinter%2FPDF-tips.pdf