To Home Page

CSC 433 -- Takehome Midterm Exam -- Spring 2015

Due May 12 at 11:59pm.

Submit a single document named like this: THMidtermSmithStan.docx or THMidtermSmithStan.txt (replace Stan by your first name and Smith by your family name). Put everything in this document, including your answers to the multiple choice questions in Part A and your source code and output for Part B.  Problems 1, 3, 4, and 5 in Part B also require additional discussion.

Part A: Multiple Choice Questions   In addition to indicating the letter of the correct answer for each question, provide an explantion of how you obtained your answer. Although you may be able to check some of the answers by running SAS source code, the SAS output by itself is not a sufficient explanation of how you obtained your answer. If you think that none of the answers is correct, indicate "None of the above" for your answer and explain why.  For each multiple choice question, the reason is worth 4 points; the correct answer is worth 1 point.

  1. This input statement is an example of which input style? Explain why the answer you choose is correct.
    a. Column       b. Formatted       c. List       d. Mixed
     
  2. In this input statement, what does the #3 do? Explain why the answer you choose is correct.
    a. Moves the column pointer three columns to the right.
    b. Moves the column pointer three records to the right.
    c. Moves the column pointer to column 1, two lines below the current line.
    d. Moves the column pointer to column 1, three lines below the current line.
     
  3. What is the output of this script? Explain why the answer you choose is correct.
  4. What is the output of this script? Explain why the answer you choose is correct.
  5. Given these two temporary SAS datasets:
    What is the first observation of the dataset merged after this script is executed? Explain why the answer you choose is correct.
  6. The dataset orig is defined like this:
    After this script is run, how many observations are in the dataset one? Explain why the answer you choose is correct.
    a. 0         b. 3         c. 5         d. 8
     
  7. If the dataset orig is defined as in Question 6, which of these scripts is correct? Explain why the answer you choose is correct.
  8. What is the output of this script?  Explain why the answer you choose is correct.

Part B: Problems

  1. Pick five interesting informats and five interesting formats and explain how they work. Write a SAS script that tests the informats by reading from a text file and also tests the formats by writing to an output text file. Use a file statement to define the output file and use put statements to write to it.
     
  2. Using the input file bank.csv in the zipfile bank.zip, create a SAS dataset named bank. See the file bank-names.txt in the zipfile for more information. Set the delimiter to ';' and use the infile option DSD. Set up labels and formats for the variables job and housing. Then create these two bar graphs:
     
    1. A bar graph that shows the precentage of persons in each type of job.
       
    2. A bar graph that shows the percentage of persons in each type of job, with subgroups on each bar showing housing (the percentage of persons that have a housing loan).

  3. Using the dataset sashelp.heart as an SQL table,
     
    1. use proc sql to find the average height, weight, and age at start for everyone in the table that is still alive.
       
    2. use proc sql to find the averages in Part a, but separately by sex.
       
    3. Find the answers to Parts a and b without using proc sql.  Instead, use one or more SAS data statements together with proc means or proc summary.

  4. Use the permanent SAS dataset finance.sas7bdat in the zip file finance.zip to do the following: use gplot or sgplot to create a graph of the following two series:
     
    1. DJIA Index Price (djiam) on the y-axis vs. date on the x-axis.
       
    2. Gold Price per Troy Ounce (gold) on the y-axis vs. date on the x-axis.

    Graph both series on the same graph, showing the y-axis for djaim on the left and the y-axis for gold on the right.  Explain the choices that you make.  See the DoubleAxis Example for help.
     
  5. This SAS macro contains errors.  After correcting the errors and use it to create permanent SAS datasets from the raw data files in states-files.zip.  This zip file contains files state1.txt, state2.txt, ... , state50.txt, one for each state. Each file contains the ten largest cities and populations for that state. List the errors that you find and explain how this macro works to someone that understands SAS, but is new to macros. Discuss any tricky points that need special attention.
     
    Here is the corrected macro.