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

Chapter 1 Getting Started Using SAS Software

Оглавление

Multiple Choice

Short Answer

Programming Exercises

Multiple Choice

1. Which of the following is not a comment in SAS?

a. /* I am not a comment */

b. * I am not a comment ;

c. /* * I am not a comment; */

d. All of the above are valid comments

2. What other term is appropriate for referring to a SAS data set?

a. A column

b. A row

c. A table

d. None of the above

3. Which of the following is a valid variable name when using the VALIDVARNAME=V7 option?

a. AbCdEfGhIjKlMnOpQrStUvWxYz

b. %Change

c. Debt-Ratio

d. 1stProcedure

4. In SAS data sets, missing numeric data are represented by which of the following?

a. A single space

b. A single period

c. Any number of spaces

d. Any of the above

5. What is the main difference in the naming convention for SAS data libraries versus SAS variables?

a. SAS data library names can contain special characters such as $, % and #

b. Variable names are case sensitive

c. SAS data library names can only be up to 8 characters long

d. Variable names can contain underscores

6. What is a SAS data library?

a. A location where SAS data sets are stored

b. A location where the SAS log messages are stored

c. A location where SAS procedure results are stored

d. All of the above

7. How many SAS statements does this program contain?

DATA instock; INFILE supply;

INPUT Brand $

Model $

Quantity;

RUN;

PROC PRINT DATA = instock;

RUN;

a. 2

b. 3

c. 6

d. 7

8. Which statement does not indicate the end of a DATA or PROC step?

a. STOP

b. QUIT

c. END

d. RUN

9. By default, SAS will execute the DATA step one time each for which of the following?

a. Variable

b. Observation

c. Data set

d. Procedure

10. Which of the following is not an interactive environment for editing and submitting SAS programs?

a. SAS windowing environment

b. SAS Studio

c. SAS Enterprise Guide

d. Batch mode

11. What will the value of F be in the data set called TEMPS?

DATA temps;

F = (C * 9/5) + 32;

C = 0;

RUN;

a. .

b. 0

c. 32

d. 34

12. In the SAS windowing environment, you can edit SAS data sets by using which of the following?

a. Results Viewer

b. Output window

c. Results window

d. Viewtable window

13. If a program does not run correctly, where can you find the error messages?

a. The end of the program

b. The log

c. The results

d. The output

14. When you submit a SAS program in an interactive environment, which window or tab will always show activity?

a. Enhanced Editor

b. Log

c. Results

d. Output

15. Which of the following is true about OPTIONS statements?

a. They are specified in DATA steps

b. They are global

c. These statements modify your default settings for future SAS sessions

d. The first OPTIONS statement in a program overrides subsequent ones

16. Suppose you submit the following code. Any output formatted for printing that is created after this statement will have what characteristics?

OPTIONS NUMBER NOCENTER;

a. Left-justified with no page numbers and no date

b. Left-justified with no page numbers with today’s date

c. Left-justified with page numbers and no date

d. Left-justified with page numbers with today’s date

Short Answer

17. Would the layout of the following PROC PRINT code cause SAS to produce an error? Explain why or why not, and rewrite the code so that it is more organized.

PROC

PRINT

DATA = new; RUN;

18. SAS ignores anything inside a comment. Explain why it is a good idea to add comments to your program.

19. Suppose that you need to record information on the annual salary of employees as a variable in a SAS data set. Would it be better to store this information as a character or numeric variable? Explain your choice.

20. A coworker tells you, “SAS programs always start with a DATA step.” Is this true? Explain why or why not.

21. Explain why SAS data sets are self-documenting.

22. Which will occur first: execution of the last statement in the DATA step or reading of the last observation in an input data set? Explain your choice.

23. Explain in what order SAS processes observations in a DATA step.

24. Explain why it is a good idea to check your SAS log.

25. Describe what a global statement is and identify two such statements.

26. Explain why using the OPTIONS statement is the most flexible way to specify a system option.

Programming Exercises

27. The body mass index (BMI) is a measure used as a rough indicator of an individual’s body fat. The following program computes BMI using weight (in pounds) and height (in inches).

** Compute Body Mass Index using pounds and

inches;

DATA bodymass;

Gender = ‘Male’;

Weight = 150;

Height = 68;

BMI = (Weight / Height ** 2) * 703;

RUN;

a. Type this program into the editor and submit it.

b. This program creates a SAS data set named BODYMASS in the WORK library. View the data set. Find the value that was calculated for the BMI variable and record this value as a comment in your program.

c. View the properties of the data set to identify the type of each variable and record them as comments in your program. How you view the properties varies depending on what SAS interface you are using.

d. Choose different values for the variables Weight and Height in your program. Add a PROC PRINT to list the data in the BODYMASS data set and submit the revised program.

28. SAS system options control many aspects of the way SAS runs. You can list the current values of system options using the OPTIONS procedure. You can change the value of system options using the OPTIONS statement.

a. Write a program that contains the OPTIONS procedure, and submit it.

b. In your SAS log, find the following options: MISSING=, OBS=, PAPERSIZE=, and YEARCUTOFF=. Add comments to your program stating the current values of these options.

c. Using an OPTIONS statement, change the option CENTER to NOCENTER. Then add another PROC OPTIONS to your program and submit the new SAS statements. Check your log to confirm that the option has been changed to NOCENTER.

29. The following DATA step attempts to create a SAS data set that contains information about a city.

OPTIONS NONUMBR;

DATA info;

City = ‘Sao Paulo’;

Country = ‘Brazil’

CountryCode = 55;

CityCode = 11;

RUN;

a. Type this program into SAS and submit it. Review the information in the SAS log. In a comment in your program, identify the number of notes, warnings, and errors produced by this code (not including any start-up messages).

b. Revise the code to fix the programming mistakes, and then resubmit it.

c. Review the information in the SAS log. In a comment in your program, identify how many observations and variables were created in this data set.

Exercises and Projects for The Little SAS Book, Sixth Edition

Подняться наверх