+ All Categories
Home > Documents > MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05,...

MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05,...

Date post: 28-Jul-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
14
1 MATH 707-ST: Introduction to Statistical Computing with SAS and R MID-TERM EXAM (Writing part) Fall, 2013 (Time allowed: TWO Hours) Highlight your answer clearly for each question. There is only one correct answer for each question. 1. Given the SAS data set EMPLOYEES: NAME SALARY -------- ----------- Innis 60000 Jolli 50000 Ellis 55000 Liu 45000 The following SAS program is submitted: proc print data = employees; where name like '_i%'; run; What is contained in the output? a. Innis, Ellis, and Liu only b. Liu only c. Innis, Jolli, Ellis, and Liu d. Innis and Ellis only 2. A raw data file is listed below. 1---+----10---+----20---+--- 01/05/1989 Frank 11 12/25/1987 June 13 01/05/1991 Sally 9 The following SAS program is submitted using this file as input: data work.family; infile 'file-specification'; input @1 date_of_birth mmddyy10. @15 first_name $5. @25 age 3; run; proc print data=work.family noobs; run; The following output is generated for the Work.Family data set:
Transcript
Page 1: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

1

MATH 707-ST: Introduction to Statistical Computing with SAS and R

MID-TERM EXAM (Writing part)

Fall, 2013

(Time allowed: TWO Hours)

Highlight your answer clearly for each question. There is only one correct answer for each question. 1. Given the SAS data set EMPLOYEES:

NAME SALARY -------- ----------- Innis 60000 Jolli 50000 Ellis 55000 Liu 45000 The following SAS program is submitted:

proc print data = employees; where name like '_i%'; run;

What is contained in the output?

a. Innis, Ellis, and Liu only b. Liu only

c. Innis, Jolli, Ellis, and Liu d. Innis and Ellis only

2. A raw data file is listed below.

1---+----10---+----20---+---

01/05/1989 Frank 11

12/25/1987 June 13

01/05/1991 Sally 9

The following SAS program is submitted using this file as input: data work.family;

infile 'file-specification'; input @1 date_of_birth mmddyy10. @15 first_name $5. @25 age 3; run;

proc print data=work.family noobs; run;

The following output is generated for the Work.Family data set:

Page 2: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

2

Date_of_birth First_name Age

10597 Frank .

10220 June .

11327 Sally .

Which of the following statements is true regarding the Work.Family output?

a. The output has the expected data values. b. The output does not have the expected data values due to an invalid data set name. c. The output does not have the expected data values due to an invalid informat for Age only. d. The output does not have the expected data values due to invalid informats for both Age and

Date_of_birth.

3. The following SAS program is submitted:

data employees; infile 'file-specification'; input @1 name $10.

@15 date date9. @25 department $;

run; How many numeric variables are created?

a. 0 b. 1 c. 2 d. 3

4. A raw data file is listed below.

1---+----10---+----20---+---

Jose,47,210

Sue,,108

The following SAS program is submitted using this file as input: data employeestats; <insert INFILE statement here>; input name $ age weight; run; The following output is desired:

name age weight

Jose 47 210

Sue . 108

Which of the following INFILE statements completes the program and accesses the data correctly?

a. infile 'file-specification' pad; b. infile 'file-specification' dsd; c. infile 'file-specification' missover;

Page 3: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

3

d. infile 'file-specification' dlm=',';

5. When the following SAS program is submitted, the data set SASDATA.PRDSALES contains 2000 observations: libname sasdata 'SAS-data-library'; options obs = 500; proc print data = sasdata.prdsales (firstobs = 100); run; options obs = max; proc means data = sasdata.prdsales (firstobs = 300); run; How many observations are processed by each procedure?

a. 400 for PROC PRINT, 1700 for PROC MEANS b. 401 for PROC PRINT, 1701 for PROC MEANS c. 401 for PROC PRINT, 1700 for PROC MEANS d. 500 for PROC PRINT, 2000 for PROC MEANS

6. A raw data file is listed below.

1---+----10---+----20---+----30---+----40---+----50

TWOSTORY 1040 2 1SANDERS ROAD $55,850

CONDO 2150 4 2.5JEANS AVENUE $127,150

The following program is submitted using this file as input: data work.houses; infile 'file-specification'; <insert INPUT statement here> run; Which one of the following INPUT statements reads the raw data file correctly?

a. input @1 style $8. +1 sqfeet 4. +1 bedrooms 1. @20 baths 3. street 16. @40 price dollar8.; b. input @1 style $8 +1 sqfeet 4. +1 bedrooms 1. @20 baths 3. street $16. @40 price dollar8.; c. input @1 style $8. +1 sqfeet 4. +1 bedrooms 1. @20 baths 3. street $16. @40 price dollar8.; d. input @1 style $8. +1 sqfeet 4. +1 bedrooms 1. @20 baths 3 street 16. @40 price dollar8.;

7. The following SAS program is submitted at the start of a new SAS session:

libname sasdata2008 'SAS-data-library'; data sasdata.sales; set sasdata2008.salesdata; profit=expenses-revenues; run; proc print data=sasdata.sales; run; The SAS data set Salesdata has 10 observations. Which one of the following answers explains why a report

fails to generate?

a. The DATA step fails to execute.

Page 4: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

4

b. The SAS data set Sales has 10 observations.

c. The SAS data set Sales does not exist in the work library.

d. The PRINT procedure statement syntax is incorrect.

8. The following SAS program is submitted: data work.clients; calls=6; do until(calls gt 9); calls+1; end; calls+1; run; What is the result?

a. The variable Calls has a value of 9 in the output data set. b. The variable Calls has a value of 10 in the output data set. c. The variable Calls has a value of 11 in the output data set. d. The variable Calls has no value. The program fails to execute.

9. The following SAS program is submitted:

proc sort data=payroll; by EmployeeIDNumber; run;

How are the observations sorted?

a. Payroll is re-created in sorted order by EmployeeIDNumber.

b. Payroll is stored in original order, and a new data set Payroll is created in sorted order by

EmployeeIDNumber.

c. Payroll is stored in original order, and a new data set Payrollsorted is created in sorted order by

EmployeeIDNumber.

d. Payroll is re-created in sorted order by EmployeeIDNumber, and a new data set Payroll is created in sorted

order by EmployeeIDNumber.

10. Which one of the following SAS programs creates a variable named City with a value of Chicago?

a. data work.airports; AirportCode='ord'; if AirportCode='ORD' City='Chicago'; run;

b. data work.airports; AirportCode='ORD'; if AirportCode='ORD' City='Chicago'; run;

c. data work.airports; AirportCode='ORD'; if AirportCode='ORD' then City='Chicago'; run;

d. data work.airports; AirportCode='ORD';

Page 5: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

5

if AirportCode='ORD'; then City='Chicago'; run;

11. The SAS data set Employees is listed below.

Employees

Name Salary

Patel 60000

Payne 50000

Ellis 55000

Liu 45000

The following SAS program is submitted: proc print data=employees; where name ? 'e' and name contains ‘E’; run;

What is the result?

a. No observations are written to the report.

b. The observation for Ellis only is written to the report.

c. The observations for Patel and Payne only are written to the report.

d. The observations for Patel, Payne, and Ellis only are written to the report.

12. The following SAS program is submitted:

proc sort data=houses; by style; run; proc print data=houses; <insert SAS statement(s) here> run; The following list report is generated:

style bedrooms baths price

CONDO 2

3

4

2

1.5

2.5

2.5

2.0

$80,050

$79,350

$127,150

$110,700

TWOSTORY 4 3.0 $107,250

Page 6: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

6

2

2

4

1.0

1.0

2.5

$55,850

$569,250

$102,950

Which of the following SAS statements completes the program and creates the desired report?

a. id style; var bedroom baths price;

b. id style; var style bedrooms baths price;

c. id style; by style; var bedrooms baths price;

d. id style; by style; var style bedrooms baths price;

13. The following SAS program is submitted: options pageno=3 number; proc print data=sasuser.houses; run; proc means data=sasuser.shoes; run;

The report created by the PRINT procedure generates five pages of output. What is the page number on the first

page that is generated by the MEANS procedure?

a. 3 b. 4 c. 7 d. 8

14. The descriptor and data portions of the Work.Salaries data set are shown below.

Variable Type Len Pos

name Char 8 0

salary Char 8 16

status Char 8 8

The following SAS program is submitted:

proc print data=work.salaries; where salary<20000; run;

No observations are output. Which of the following answers would result in a report of individuals with Salary less than $20,000 upon re-execution of the program?

a. Right justify the Salary value in the WHERE statement in the PRINT step. b. Use a PUT function to write the Salary values with leading zeroes in a DATA step before the PRINT step.

name status salary

Liz S 15,600

Herman S 26,700

Marty S 35,000

Page 7: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

7

c. Change 20000 (which is a numeric constant) to '20,000' (which is a character constant) in the WHERE statement in the PRINT step.

d. Change the < operator to the le operator in the WHERE statement in the PRINT step.

15. input @1 name $8. @10 siblings 1. @12 bdate mmddyy10.

@23 allowance comma2. @26 hobby1 $10. @36 hobby2 $10. @46 hobby3 $10.;

What is the length of bdate and hobby1? a. bdate = 8 and hobby1 = 8 b. bdate = 8 and hobby1 = 10 c. bdate = 10 and hobby1 = 8 d. bdate = 10 and hobby1 = 10

16. The following SAS program is submitted:

data work.flights;

destination = 'CPH';

select(destination);

when('LHR') CITY = 'London';

when('FRA') CITY = 'Frankfurt';

otherwise;

end;

run;

What are the length and value of the CITY variable?

a. length is 6, value is CPH

b. length is 9, value is London

c. length of 6, value is ‘ ‘ (missing character value)

d. length of 9, value is Frankfurt

17. Given the following DATA step:

data loop;

x = 0;

do index = 1 to 5 by 2;

x = index ;

end;

run;

Upon completion of execution, what are the values of the variables X and INDEX in the SAS data set named

LOOP?

a. x = 3, index = 3

b. x = 3, index = 4

c. x = 5, index = 5

d. x = 5, index = 6

e. x = 5, index = 7

Page 8: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

8

18. The following SAS SORT procedure step generates an output data set: proc sort data = sasuser.houses out = report; by style; run;

In which library is the output data set stored? a. WORK b. REPORT c. HOUSES d. SASUSER

19. SAS treats Date as a numeric value. The initial date that is recorded as the value 0 is

(a) 01/01/1980 (b) 01//01/1970 (c) 01/01/1960 (d) 01/01/1950

20. Which of the following is a correct format for a specific date on 12/31/2000 for the following IF statement

IF hireddate = _________________ then bonus = salary * .15;

(a) 12/31/2000 (b) ‘31DEC2000’d (c) DEC302000 (d) ‘12/31/2000’d (e) ‘DEC312000’d

21. Which of the following format reads the Date 12NOV2004:

(a) Date9. (b) DDMMYY9. (c) DDMMMYYYY9. (d) None of the above

22. In a SAS program, when INFILE statement is used, the DATA step usually reads

(a) procedure for analyze data (b) external data file (c) SAS data file (d) none of these

23. How many observations are in the output from the following program, assuming the SAS data set old has more than 20 observations:

Options firstobs=6 obs = 20;

Data new1; set old;

Run;

PROC PRINT data = work.new1; RUN;

(a) None (b) 5 (c) 10 (d) 15 (e) 25

Page 9: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

9

24. How many observations are in the output from the following program, assuming the SAS data set old has more than 20 observations:

Options firstobs=6 obs = 20;

Data new1; set old;

If _N_ > 10; RUN;

PROC PRINT data = work.new1 (firstobs = 1); RUN;

(a) None (b) 5 (c) 10 (d) 15 (e) 25

25. What happens if you submit the following program? PROC SORT data = clinic.diabetes ; run;

PROC PRINT data = clinic.diabetes;

Var age height weight pulse;

Where sex = ‘F’ ;

RUN;

(a) The PROC SORT step runs successfully, but the PROC PRINT step generates errors and stop processing. (b) The PROC PRINT step runs successfully, printing observations in their sorted order. (c) The PROC SORT step permanently sorts the input data set. (d) The RPCO SORT step generates errors and stops processing, but the PROC PRINT step runs successfully,-

printing observations in their original (unsorted) order.

26. Which of the following programs correctly read the Excel file, salary.xlsx stored in the folder Ex_data in D-drive:

(a) Libname Excell_data ‘D:\Ex_data\salary.xlsx’ ; Data salary; Set Excell_data.’salary$’n ; RUN;

(b) Libname Ex_data ‘D:/Ex_data/salary.xlsx’ ; Data salary; Set Ex_data.salary; RUN;

(c) Libname Ex_data ‘D:\Ex_data\salary.xlsx’ ; Data salary; Set Ex_data.salary.xlsx; RUN;

(d) Libname Ex_data ‘D:\Ex_data\salary.xlsx’ ;

Data salary; Set Ex_data.’salary$’n ; RUN;

Page 10: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

10

27. Suppose you run a program that causes three DATA step errors. What is the value of the variable _ERROR_ when the observation that contains the third error is processed?

(a) 0 (b) 1 (c) 2 (d) 3 28. The following observation is stored in a SAS data set named EMPLOYEES:

LNAME FNAME JOBCODE

----------------------------------------------------------------------

Whitley Sam NA1

If the DATA step below is executed, what will be the value of the variable JOBDESC in the output SAS data

set when this observation is processed:

data navigate; set employees; if jobcode = 'NA1' then jobdesc = 'Navigator'; run; a. navigator b. Navigator c. NAVIGATOR d. a missing value

29. The below three program blocks are submitted

A) Data target_data ; Set base_data (keep = var1 var2 var3 ); Run;

B) Data target_data ; Set base_data; keep = var1 var2 var3 ;

Run;

C) Data target_data (keep = var1 var2 var3 );

Set base_data;

Run;

If the user needs only var1, var2 and var3 to work with, which step is most efficient?

a. A b. B c. C d. A&B e. None

30. The following SAS program is submitted:

Page 11: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

11

data test(drop=age);

set sashelp.class(keep=name age gender height weight);

drop=gender; newage=age+1; run;

Sashelp.Class contains 5 variables. What is the result?

a. No variables are written to the data set Work.Test.

b. 4 variables are written to the data set Work.Test.

c. 5 variables are written to the data set Work.Test.

d. 6 variables are written to the data set Work.Test.

31. The following SAS program is submitted:

data _null_;

set old(keep=sales1 sales2);

file 'file-specification';

put sales1 sales2;

run;

What is the result?

a. A raw data file is created with no delimiter separating the fields.

b. A raw data file is created with a space delimiter separating the fields.

c. A raw data file is created with a comma delimiter separating the fields.

d. No raw data file is created. The DATA step fails execution because no delimiter is specified.

32. The following statements are submitted

Data Test;

today = '20dec2005'd;

format today mmddyy10.;

run;

Which of the following statement is true ?

a. ‘Today’ variable displays like ‘12/20/2005’

b. Data step not executed due to wrong format ‘mmddyy’.

c. Today is displayed as ‘20DEC2005’

33. What is the result from running the following program in the data set score:

Page 12: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

12

Data rawscore;

Input name $ Quiz1 Quiz2 @@;

Datalines;

Tom 20 18 Jerry 17 16 Mike 16 12 Julie 20 20 Jean 17 15

;

Run;

Data score;

Set rawscore point = 3;

Output; stop;

run;

a. None, since there is a syntax error in the SET statement. b. None since the rawscore data set only consists of one observation. c. It has one observation, which is Mike 16 12 d. It has one observation, which is Tom 20 18

34. What is the result from running the following program in the data set score:

Data rawscore;

Input name $ Quiz1 Quiz2 @@;

Datalines;

Tom 20 18 Jerry 17 16 Mike 16 12 Julie 20 20 Jean 17 15

;

Run;

Data score;

num=3;

Set rawscore point = num;

stop;

run;

a. None, since there is a syntax error in the SET statement. b. None since the SAS program can not reach the end of file.

Page 13: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

13

c. None since the SAS program can not reach the end of the Data Step is make the implicit output. d. It has one observation, which is Mike 16 12 e. It has one observation, which is Tom 20 18

Answer Q35 to Q38 based on the following submitted program:

Input name $ gender $ Quiz1 Quiz2 @@;

Datalines;

Tom M 20 18 Jerry M 18 15 Mike M 16 12 Julie F 20 20 Jean F 17 15

; Run;

proc print; run;

Proc sort; by gender; run;

Data score (keep= gender Avg_q1 Avg_q2);

Set rawscore (drop = name); BY gender;

Ncase+1; Sumq1+quiz1; Sumq2+quiz2;

If last.gender then

do;

Avg_q1=sumq1/ncase; Avg_q2=sumq2/ncase; ncase = 0; sumq1=0; sumq2=0;

output;

End;

run;

proc print; run;

35. How many variables are created in the Program data Vector in the Data Step: Data Score prior to output to the Score data set:

a. 3 b. 4 c. 5 d. 9 e. 15

36. How many variables are outputs to the SAS data Score: a. 3 b. 4 c. 5 d. 9 e. 10

Page 14: MATH 707-ST: Introduction to Statistical Computing with ...wguo/Math707ST_2013/Math707...Jan 05, 1989  · Patel 60000 Payne 50000 Ellis 55000 Liu 45000 The following SAS program is

14

37. What is the Avg_q1 for Gender = ‘F’ after running the program? a. 20 b. 18.5 c. 18.0 d. 15.0 e. Cannot be computed due to syntax error

38. If we delete the statement OUTPUT; from the program, what is the effect on the data set Score? a. There is no effect. b. The number of observations is decreased from 5 to 2 c. The number of observations is increased from 2 to 5 d. The program will have syntax error.

39. In a SAS program, the PROC step usually reads

(a) procedure for analyze data (b) external data file (c) SAS data file (d) none of these

40. Which of the following statements selects from a data set only those observations for which the value of the variable Style is RANCH, SPLIT, or TWOSTORY?

(a) WHERE STYLE = ‘RANCH’ OR ‘SPLIT’ OR ‘TWOSTORY’ ; (b) WHERE STYLE IN ‘RANCH’ OR ‘SPLIT’ OR TWOSTORY’ ; (c) WHERE STYLE IN (‘RANCH’ , ‘SPLIT’ , ‘TWOSTORY’ ) ; (d) WHERE STYLE IN (RANCH, SPLIT , TWOSTORY ) ;

ANSWERS:

1. b 2. c 3. b 4. b 5. b 6. c 7. a 8. c 9. a 10. c

11. a 12. c 13. d 14. c 15. b 16. c 17. e 18. a 19. c 20. b

21. a 22. b 23. d 24. b 25. d 26. d 27. b 28. b 29. a 30. d

31. b 32. a 33. a 34. a 35. d 36. b 37. b 38. c 39. c 40. c


Recommended