Exercises and Projects for The Little SAS Book, Sixth Edition. Lora D. Delwiche. Читать онлайн. Newlib. NEWLIB.NET

Автор: Lora D. Delwiche
Издательство: Ingram
Серия:
Жанр произведения: Программы
Год издания: 0
isbn: 9781642955255
Скачать книгу
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. 215

      6. Which function can be used to replace text?

      a. TRIM

      b. INDEX

      c. TRANWRD

      d. PROPCASE

      7. Which of the following is a valid function for finding the average of X1, X2, and X3?

      a. AVERAGE(X1,X2,X3)

      b. AVG(X1,X2,X3)

      c. MEAN(X1,X2,X3)

      d. MU(X1,X2,X3)

      8. What will SAS return for the value of X?

      X = MIN(SUM(1,2,3),56/8,N(8));

      a. 1

      b. 6

      c. 8

      d. .

      9. Which of the following IF-THEN statements will not assign a value of 1 to the variable named Flag for patients with an eye color of blue or brown?

      a. IF EyeColor = ‘blue’ OR ‘brown’ THEN Flag = 1;

      b. IF EyeColor = ‘blue’ OR EyeColor = ‘brown’ THEN Flag = 1;

      c. IF EyeColor IN (‘blue’,’brown’) THEN Flag = 1;

      d. All of the above will work

      10. Which set of IF-THEN/ELSE statements will run without errors?

      a. IF 0 <= Age <= 50 THEN Group = ‘A’;

       ELSE 50 < Age <=70 THEN Group = ‘B’;

       ELSE Age > 70 THEN Group = ‘C’;

      b. IF 0 <= Age <= 50 THEN Group = ‘A’;

       ELSE IF 50 < Age <= 70 THEN Group = ‘B’;

       ELSE Age > 70 THEN Group = ‘C’;

      c. IF 0 <= Age <= 50 THEN Group = ‘A’;

       ELSE IF 50 < Age <= 70 THEN Group = ‘B’;

       ELSE IF Age > 70 THEN Group = ‘C’;

      d. All of the above will work

      11. Given the following raw data and program, how many observations will be in the resulting SAS data set?

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

      41 25 male

      32 79 female

      36 52 female

      74 63 male

      DATA pts;

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

      INPUT ID Age Gender $;

      IF Age < 75;

      IF Age < 50 AND Gender = ‘female’ THEN

      Guideline = ‘Inv4a’;

      ELSE IF Age >= 50 AND Gender = ‘female’ THEN

      Guideline = ‘Inv4b’;

      ELSE Guideline = ‘n/a’;

      RUN;

      a. 1

      b. 2

      c. 3

      d. 4

      12. How many clauses are in the following SQL step?

      PROC SQL;

      SELECT Name, Address, Phone, Email

      FROM contacts;

      QUIT;

      a. 1