Exercises and Projects for The Little SAS Book, Sixth Edition. Lora D. Delwiche

Чтение книги онлайн.

Читать онлайн книгу Exercises and Projects for The Little SAS Book, Sixth Edition - Lora D. Delwiche страница 9

Автор:
Жанр:
Серия:
Издательство:
Exercises and Projects for The Little SAS Book, Sixth Edition - Lora D. Delwiche

Скачать книгу

and read it into a permanent SAS data set using the IMPORT procedure.

      b. Print a report that describes the contents of the data set including the attributes of the variables and data set.

      c. In a comment in your program, discuss any limitations of the functionality of the resulting data set.

      d. Print the Oscars.xlsx data file using the XLSX LIBNAME engine. In a comment in your program, discuss any limitations of using this method to read in the data.

      55. Researchers randomly assigned subjects to either a treatment group taking a cholesterol-lowering medication daily, or a control group taking a placebo daily. The difference in total cholesterol was measured after four months. The variables in the Tchol.dat file are subject ID, treatment group, difference in cholesterol, pre-treatment total cholesterol, and post-treatment total cholesterol.

      a. Examine the raw data file Tchol.dat and read it into SAS.

      b. Print the data set.

      c. Create a new DATA step and read in the data for only the subjects assigned to the treatment group. Do this as efficiently as possible by testing the treatment group variable as it is being read in with the INPUT statement.

      d. Print the data set.

      56. A gourmet pizza restaurant is considering adding new toppings to its menu. Each month they survey 10 customers about their preferences for three different toppings. They want data on several different toppings, so they don’t always ask about the same three toppings. Customers rate each topping on a scale of 1 (would never order) to 5 (would order often). The restaurant wants to compute average ratings for all toppings, so the ratings variables need to be numeric. The raw data file Pizza.csv has variables for the respondent’s survey number, and the ratings for five different toppings: arugula, pine nuts, roasted butternut squash, shrimp, and grilled eggplant. The first two digits in the survey number correspond to the month of the survey.

      a. Examine the raw data file Pizza.csv and read it into SAS using the IMPORT procedure.

      b. Print the data set.

      c. Print a report that describes the contents of the data set to make sure all the variables are the correct type.

      d. Open the raw data file in a simple editor like WordPad and compare the data values to the output from parts b) and c) to make sure that they were read correctly into SAS. In a comment in your program, identify any problems with the SAS data set that cannot be resolved using the IMPORT procedure.

      e. Read the same raw data file, Pizza.csv, this time using a DATA step. Be sure to resolve any issues identified in part d).

      f. Print the data set.

      57. The Microsoft Excel file named CarTalk.xlsx contains information regarding episodes of the automotive repair radio talk show Car Talk. Variables in this file include episode number, air date, title, and a description of the show.

      a. Examine the Microsoft Excel file Cartalk.xlsx by printing the Excel spreadsheet using the XLSX LIBNAME engine.

      b. Read the Microsoft Excel file Cartalk.xlsx into a SAS data set using the XLSX LIBNAME engine.

      c. Read the Microsoft Excel file into a SAS data set using PROC IMPORT.

      d. Print the two SAS data sets.

      e. Read the rows of the Excel file that correspond to the month of May into SAS using the IMPORT procedure. Print the data set.

      Chapter 3

      Working with Your Data

       Multiple Choice

       Short Answer

       Programming Exercises

      Multiple Choice

      1. Which DATA step will not overwrite a temporary SAS data set called TOYS?

      a. DATA WORK.toys; SET WORK.toys; RUN;

      b. DATA ‘c:\MySASLib\toys’; SET ‘c:\MySASLib\toys’; RUN;

      c. DATA toys; SET toys; RUN;

      d. None of the above

      2. Which SAS statement can be used to read a SAS data set?

      a. SET

      b. INFILE

      c. INPUT

      d. All of the above

      3. Which of the following assignment statements is valid for the numeric variable Score?

      a. Score / 100;

      b. Score = Score / 100;

      c. Score = ‘Score’ / 100;

      d. Score = ‘Score / 100’;

      4. Given the following raw data and program, what will be the value of Total1 for the second observation in the resulting SAS data set?

      ----+----1----+----2

      1 160 50 20

      2 150 55 .

      3 120 40 30

      4 140 50 25

      DATA cholesterol;

      INFILE ‘c:\MyRawData\Patients.dat’;

      INPUT ID Ldl Hdl Vldl;

      Total1 = Ldl + Hdl + Vldl;

      RUN;

      a. 230

      b. 205

      c. .

      d. 215

      5. Given the following raw data and program, what will be the value of Total2 for the second observation in the resulting SAS data set?

      ----+----1----+----2

      1 160 50 20

      2 150 55 .

      3 120 40 30

      4 140 50 25

      DATA cholesterol;

       INFILE ‘c:\MyRawData\Patients.dat’;

      INPUT ID Ldl Hdl Vldl;

      Total2 = SUM(Ldl,Hdl,Vldl);

      RUN;

      a. 230

      b. 205

      c. .

      d.

Скачать книгу