38
1 STAT 475 HOMEWORK 2 SOLUTION Exercise 1. data earthquakes; infile "<…>/earthquakes_Ex1.txt"; input date YYMMDD10. time TIME12. magnitude latitude longitude; run; proc print; format date DATE9. time TIME7.; run; Obs date time magnitude latitude longitude 1 10JAN2022 14:54 0.36 33.512 -116.768 2 10JAN2022 15:16 0.96 33.184 -116.031 3 10JAN2022 15:43 1.09 35.680 -117.535 4 10JAN2022 16:33 0.68 33.588 -116.808 5 10JAN2022 17:14 0.86 36.032 -117.807 6 10JAN2022 18:00 0.61 35.765 -117.580 7 10JAN2022 18:50 0.90 35.586 -117.462 8 10JAN2022 18:59 2.61 35.648 -115.927 9 10JAN2022 19:39 0.78 35.693 -117.537 10 10JAN2022 20:10 1.93 32.202 -116.061 11 10JAN2022 20:24 1.23 33.341 -117.146 12 10JAN2022 21:08 0.90 35.586 -117.462 13 10JAN2022 21:18 0.90 35.586 -117.462 14 10JAN2022 21:31 1.56 36.439 -118.080 15 10JAN2022 22:29 0.95 35.750 -117.566 16 10JAN2022 22:33 0.90 35.999 -117.833 17 10JAN2022 22:36 1.82 34.976 -119.132 18 10JAN2022 22:45 2.15 33.618 -117.253 Exercises for Handout 5: Chapter 2 Quiz: 3) In order for the date values 05May1955 and 04Mar2046 to be read correctly, what value must the YEARCUTOFF= option have?

STAT 475 HOMEWORK 2 SOLUTION Exercises for Handout 5:

Embed Size (px)

Citation preview

1

STAT 475 HOMEWORK 2 SOLUTION Exercise 1. data earthquakes; infile "<…>/earthquakes_Ex1.txt"; input date YYMMDD10. time TIME12. magnitude latitude longitude; run; proc print; format date DATE9. time TIME7.; run;

Obs date time magnitude latitude longitude 1 10JAN2022 14:54 0.36 33.512 -116.768 2 10JAN2022 15:16 0.96 33.184 -116.031 3 10JAN2022 15:43 1.09 35.680 -117.535 4 10JAN2022 16:33 0.68 33.588 -116.808 5 10JAN2022 17:14 0.86 36.032 -117.807 6 10JAN2022 18:00 0.61 35.765 -117.580 7 10JAN2022 18:50 0.90 35.586 -117.462 8 10JAN2022 18:59 2.61 35.648 -115.927 9 10JAN2022 19:39 0.78 35.693 -117.537

10 10JAN2022 20:10 1.93 32.202 -116.061 11 10JAN2022 20:24 1.23 33.341 -117.146 12 10JAN2022 21:08 0.90 35.586 -117.462 13 10JAN2022 21:18 0.90 35.586 -117.462 14 10JAN2022 21:31 1.56 36.439 -118.080 15 10JAN2022 22:29 0.95 35.750 -117.566 16 10JAN2022 22:33 0.90 35.999 -117.833 17 10JAN2022 22:36 1.82 34.976 -119.132 18 10JAN2022 22:45 2.15 33.618 -117.253

Exercises for Handout 5: Chapter 2 Quiz: 3) In order for the date values 05May1955 and 04Mar2046 to be read correctly, what value must the YEARCUTOFF= option have?

2

a. value between 1947 and 1954, inclusive – This answer is INCORRECT as four digit year inputs do not rely on the YEARCUTOFF option and are read correctly assuming the informat width is set to read the entire date value.

b. 1955 or higher – This answer is INCORRECT as four digit year inputs do not rely on the YEARCUTOFF option and are read correctly assuming the informat width is set to read the entire date value.

c. 1946 or higher – This answer is INCORRECT as four digit year inputs do not rely on the YEARCUTOFF option and are read correctly assuming the informat width is set to read the entire date value.

d. any value – This is the CORRECT answer because if the informat width is set correctly to read in the entire date value, YEARCUTOFF does not matter. YEARCUTOFF only comes into effect when 2 digit year dates are given (eg. 2002 as “02” and 1992 as “92”).

8) Which time span is used to interpret two-digit year values if the YEARCUTOFF= option is set to 1950?

a. 1950-2049 – This is the CORRECT answer as YEARCUTOFF specifies what year the 100 year range begins at, in this case it starts at 1950 and 100 years later is 2049. (starts 1/1/1950 ends 12/31/2049)

b. 1950-2050 – This is an INCORRECT answer as this is a span of over 100 years (starts 1/1/1950 ends 12/31/2050)

c. 1949-2050 – This is an INCORRECT answer as the start date is before 1950 and the period given is over 100 years (starts 1/1/1949 ends 12/31/2050)

d. 1950-2000 – This is an INCORRECT answer as this is not a 100 year period. Chapter 18 Quiz: 1) SAS date values are the number of days since which date?

a. January 1, 1900 - This is INCORRECT as SAS Date values are the number of days from 1/1/1960 to the given date.

b. January 1, 1950 – This is INCORRECT as SAS Date values are the number of days from 1/1/1960 to the given date.

c. January 1, 1960 – This is CORRECT as SAS Date values are the number of days from 1/1/1960 to the given date.

d. January 1, 1970 – This is INCORRECT as SAS Date values are the number of days from 1/1/1960 to the given date.

2) A great advantage of storing dates and times as SAS numeric date and time values is that

a. they can easily be edited. – This is INCORRECT as all date and time values in all programs are generally easily edited.

b. they can easily be read and understood. – This is INCORRECT as SAS numeric date and time values are not easily read as they are derived from set YEARCUTOFF and beginning date options.

c. they can be used in text strings like other character values. – This is INCORRECT and not true, the values are stored as numeric characters.

d. they can be used in calculations like other numeric values. – This is the CORRECT answer as the advantage of SAS is that it reads in time and date values as numeric variables and allows us to calculate desired values much more easily.

3

3) SAS does not automatically make adjustments for daylight saving time, but it does make adjustments for:

a. leap seconds – This is INCORRECT as SAS does not adjust for leap seconds. b. leap years – This is CORRECT as SAS automatically makes adjustments for leap years. c. Julian dates – This is INCORRECT as SAS does not adjust for Julian dates. d. time zones – This is INCORRECT as SAS does not adjust for time zones.

4) An input data file has date expressions in the form 10222001. Which SAS informat should you use to read these dates?

a. DATE6. – This is INCORRECT as this is the wrong informat to use for the given date expression.

b. DATE8. – This is INCORRECT as this is the wrong informat to use for the given date expression.

c. MMDDYY6. – This is INCORRECT as the wrong width is specified. d. MMDDYY8. – This is the CORRECT answer as the first two digits will read in the month,

the second two (DD) the date, and the third two (YY) as they year. The number 8 at the end specifies the total width of the inputted value so that the entire expression may be read correctly. Note that YY in this case will read the entire 4 year digit (2001) due to the correct width of 8 being specified.

5) The minimum width of the TIMEw. informat is:

a. 4 – This is INCORRECT as the minimum width of TIMEw. informat in SAS is 5. b. 5 – This is the CORRECT answer as this is the minimum width of TIMEw. informat in

SAS. c. 6 - This is INCORRECT as the minimum width of TIMEw. informat in SAS is 5. d. 7 - This is INCORRECT as the minimum width of TIMEw. informat in SAS is 5.

6) Shown below are date and time expressions and corresponding SAS datetime informats. Which date and time expression cannot be read by the informat that is shown beside it?

a. 30May2000:10:03:17.2 DATETIME20. - This is an INCORRECT answer as SAS reads this correctly.

b. 30May00 10:03:17.2 DATETIME18. - This is an INCORRECT answer as SAS reads this correctly. c. 30May2000/10:03 DATETIME15. – This is an INCORRECT answer as SAS reads this correctly. d. 30May2000/1003 DATETIME14. – This is the CORRECT answer, the hour, minutes and

seconds value must be separated by a delimiter in order for SAS to read it in correctly. 7) What is the default value of the YEARCUTOFF= system option?

a. 1920 – This is the CORRECT answer as the default YEARCUTOFF is 1920. b. 1910 – This is an INCORRECT answer as the default YEARCTUFOFF is 1920. c. 1900 – This is an INCORRECT answer as the default YEARCTUFOFF is 1920. d. 1930 – This is an INCORRECT answer as the default YEARCTUFOFF is 1920.

4

8) Suppose your input data file contains the date expression 13APR2009. The YEARCUTOFF= system option is set to 1910. SAS will read the date as:

a. 13APR1909 – This is an INCORRECT answer as YEARCUTOFF does not affect 4 digit year values such as the one given.

b. 13APR1920 – This is an INCORRECT answer as YEARCUTOFF does not affect 4 digit year values such as the one given.

c. 13APR2009 – This is the CORRECT answer as the YEARCUTOFF range does not come into effect as the date given is a 4 digit year value.

d. 13APR2020 – This is an INCORRECT answer as YEARCUTOFF does not affect 4 digit year values such as the one given.

9) Suppose the YEARCUTOFF= system option is set to 1920. An input file contains the date expression 12/08/1925, which is being read with the MMDDYY8. informat. Which date will appear in your data?

a. 08DEC1920 – This is INCORRECT as the year would be read in as 2019 given the wrong informat code.

b. 08DEC1925 – This is INCORRECT as the year would be read in as 2019 given the wrong informat code.

c. 08DEC2019 – This is the CORRECT answer as the specified informat width is wrong; only the first 8 characters are read (it will be read as 12/08/19) and because the YEARCUTOFF option is set to 1920 (1/1/1920 to 12/31/2019), the date 12/08/2019 will appear in the data.

d. 08DEC2025 – This is INCORRECT as the year would be read in as 2019 given the wrong informat code.

10) Suppose your program creates two variables from an input file. Both variables are stored as SAS date values: FirstDay records the start of a billing cycle, and LastDay records the end of that cycle. The code for calculating the total number of days in the cycle would be:

a. TotDays=lastday-firstday; - This is an INCORRECT answer as you must subtract the last date by the first date and also add one in order to find the correct range.

b. TotDays=lastday-firstday+1; - This is the CORRECT answer as you must subtract the last date by the first date and add one in order to find the correct range.

c. TotDays=lastday/firstday; - This is an INCORRECT answer as you must subtract the last date by the first date and also add one in order to find the correct range.

d. You cannot use date values in calculations. – This is an INCORRECT answer as SAS is able to use date values in calculations due to the way they are stored.

A00-201 Practice Exam: 30) A raw data record is shown below: 07Jan2002 Which one of the following informats would read this value and store it as a SAS date value? A. date9. – This is the CORRECT answer as the date informat will correctly read in the date expression given. B. ddmonyy9. – This is an INCORRECT answer as ddmonyy9. is NOT a correct informat option. C. ddMMMyy9. - This is an INCORRECT answer as ddMMMyy9. is NOT a correct informat option.

5

D. ddmmmyyyy9. - This is an INCORRECT answer as ddmmmyyyy9. is NOT a correct informat option. A00-211 Practice Exam: 27) The following SAS program is submitted: data one; date = '04jul2005'd; format date weekdate.; run; proc print data = one; run; What output is generated? A. Obs date 1 04Jul2005 – This is an INCORRECT answer as this is a DATE9. expression. B. Obs date 1 Monday, July 4, 2005 – This is the CORRECT answer as the format specifies the date in a WEEKDATE. expression. C. Obs date 1 July 4, 2005 – This is an INCORRECT answer as it is a WORDATE expression. D. Obs date 1 Monday, 07/04/2005 – This is an INCORRECT answer as it is a MMDDYY10. expression with the week date in front of it. 29) Given the following raw data record: 07Jan2005 Which INFORMAT reads this raw data and stores it as a SAS date value? A. date9. – This is the CORRECT answer as it is a proper informat expression. B. dmy9. – This is an INCORRECT answer as this is NOT a proper informat date expression. C. ddMMMyy9. – This is an INCORRECT answer as this is NOT a proper informat date expression. D. ddmmmyyyy9. – This is an INCORRECT answer as this is NOT a proper informat date expression. 30) Given the contents of the raw data file EMPLOYEE: ----|----10---|----20---|----30 Alan 19/2/2004 ACCT Rob 22/5/2004 MKTG Mary Jane 14/3/2004 EDUC The following SAS program is submitted: data emps; infile 'employee'; input @1 name $ @15 date <insert INFORMAT here> @25 department $; run;

6

Which INFORMAT correctly completes the program? A. ddmmyyyy10. – This is an INCORRECT answer as this is NOT a proper informat date expression. B. date9. – This is an INCORRECT answer as the raw data values of the date are not appropriate for this informat expression. C. ddmmyy10. – This is the CORRECT answer as it will read in the date values given correctly. The format of the raw data is in dd/mm/yy but with width of 9, however a width of 10 will still correctly read in the data. D. ddmmyyyy9. – This is an INCORRECT answer as this is NOT a proper informat date expression. Exercises for Handout 6: Chapter 2 Quiz: 6) The following PROC PRINT output was created immediately after PROC TABULATE output. Which system options were specified when the report was created?

a. OBS=, DATE, and NONUMBER – This an INCORRECT answer as a Page Number 1 was also

specified. b. NUMBER, PAGENO=l, and DATE – This is the Correct answer as the Page number and

date options are specified. c. NUMBER and DATE only – This an INCORRECT answer as the page number is given also. d. none of the above – This is an INCORRECT answer as B is the correct answer.

Chapter 4 Quiz: 2) Which of the following PROC PRINT steps is correct if labels are not stored with the data set?

a. proc print data=allsales.totals label; label region8='Region 8 Yearly Totals'; run; This is the CORRECT answer as the label ‘Region 8 Yearly Totals’ is correctly specified.

b. proc print data=allsales.totals; label region8='Region 8 Yearly Totals'; run;

7

This is an INCORRECT answer as it does not specify “label” in the proc print command.

c. proc print data allsales.totals label noobs; run;

This is an INCORRECT answer as it does not specify “label” in the proc print command.

d. proc print allsales.totals label; run; This is an INCORRECT answer as it does not specify the label name.

5) Which options are used to create the following PROC PRINT output?

a. the DATE system option and the LABEL option in PROC PRINT – This is an INCORRECT

answer as NOOBS was also specified since no observation number column appears. b. the DATE and NONUMBER system options and the DOUBLE and NOOBS options in

PROC PRINT – This is the CORRECT answer as the page number is removed, date option specified, double spacing specified and observation column removed.

c. the DATE and NONUMBER system options and the DOUBLE option in PROC PRINT – This is an INCORRECT answer as NOOBS was also specified since no observation number column appears.

d. the DATE and NONUMBER system options and the NOOBS option in PROC PRINT – This is an INCORRECT answer as double spacing (DOUBLE) is specified.

10) What does PROC PRINT display by default? a. PROC PRINT does not create a default report; you must specify the rows and columns to be

displayed. – This is an INCORRECT answer as PROC PRINT does create a default report. b. PROC PRINT displays all observations and variables in the data set. If you want an additional

column for observation numbers, you can request it. – This is an INCORRECT answer as PROC PRINT automatically generates an observation number column.

c. PROC PRINT displays columns in the following order: a column for observation numbers, all character variables, and all numeric variables. – This is an INCORRECT answer as columns are displayed in the order that the data is inputted.

d. PROC PRINT displays all observations and variables in the data set, a column for observation numbers on the far left, and variables in the order in which they occur in the data set. – This is the CORRECT answer as PROC PRINT displays all observations and variables in a dataset and you can specify a variety of options to manipulate the displayed report.

8

A00-201 Practice Exam: 88) The SAS data set SASUSER.HOUSES contains a variable PRICE which has been assigned a permanent label of "Asking Price". Which one of the following SAS programs temporarily replaces the label "Asking Price" with the label "Sale Price" in the output? A. proc print data = sasuser.houses; label price = "sale Price"; run; B. proc print data = sasuser.houses label; label price "Sale Price"; run; C. proc print data = sasuser.houses label; label price="Sale Price"; run; D. proc print data = sasuser.houses label = "Sale Price"; run; 98) The following SAS program is submitted: footnote1 'Sales Report for last Mounth'; footnote2 'Selected Products Only'; footnote3 'All Regions'; footnote4 'All Figure in Thousands of Dollars'; proc print data = sasuser.shoes; footnote2 'All products'; run; Which one of the following contains the footnote text that is displayed in the report? A. All Products – This is an INCORRECT answer as the footnotes printed out in the report are lines 1 and 2. B. Sales Report for Last Month All Products – This is the CORRECT answer as footnote2 is specified under the proc print command, which tells SAS to print the footnotes from line 1 to 2 and this includes footnote 1. C. All Products All Regions All Figures in Thousands of Dollars – This is an INCORRECT answer as the footnotes printed out in the report are lines 1 and 2. D. Sales Report for Last Month All Products All Regions All Figures in Thousands of Dollars – This is an INCORRECT answer as the footnotes printed out in the report are lines 1 and 2. 100) Which one of the following SAS system options prevents the page number from appearing on a report?

9

A. NONUM – This is an INCORRECT answer as it does not prevent the page number from appearing in the report. B. NOPAGE – This is an INCORRECT answer as it does not prevent the page number from appearing in the report. C. NONUMBER – This is the CORRECT answer as it prevents page number from appearing in the report. D. NOPAGENUM – This is an INCORRECT answer as it does not prevent the page number from appearing in the report. 102) Which one of the following SAS system options displays the time on a report? A. TIME – This is an INCORRECT answer as it is not a valid option. B. DATE – This is the CORRECT answer that displays both the time and date in the report. C. TODAY – This is an INCORRECT answer as it is not a valid option. D. DATETIME – This is an INCORRECT answer as it is not a valid option. 103) The following SAS program is submitted: options pageno = 1; proc print data=sasuser. houses; run; proc means data=sasuser .shoes; run; The report created by the PRINT procedure step generates 5 pages of output. What is the page number on the first page of the report generated by the MEANS procedure step? A. 1 – This is an INCORRECT answer as the code submitted above first generates 5 pages of the proc print step and then on page 6 generates the MEANS procedure step. B. 2 – This is an INCORRECT answer as the code submitted above first generates 5 pages of the proc print step and then on page 6 generates the MEANS procedure step. C. 5 – This is an INCORRECT answer as the code submitted above first generates 5 pages of the proc print step and then on page 6 generates the MEANS procedure step. D. 6 – This is the CORRECT answer as the code submitted above first generates 5 pages of the proc print step and then on page 6 generates the MEANS procedure step. A00-211 Practice Exam: 60) The following SAS program is submitted: footnote1 'Sales Report for Last Month'; footnote2 'Selected Products Only'; footnote3 'All Regions'; footnote4 'All Figures in Thousands of Dollars'; proc print data = sasuser.shoes; footnote2 'All Products';

10

run; Which footnote(s) is/are displayed in the report? A. Sales Report for Last Month All Products – This is the CORRECT answer as footnote2 is specified under the proc print command, which tells SAS to print the footnotes from line 1 to 2 and this includes footnote 1. B. All Products All Regions All Figures in Thousands of Dollars – This is an INCORRECT answer as the footnotes printed out in the report are lines 1 and 2. C. All Products – This is an INCORRECT answer as the footnotes printed out in the report are lines 1 and 2. D. Sales Report for Last Month All Products All Regions All Figures in Thousands of Dollars – This is an INCORRECT answer as the footnotes printed out in the report are lines 1 and 2. Exercises for Handout 7: Chapter 4 Quiz: 1) Which PROC PRINT step below creates the following output?

a.

proc print data=flights.laguardia noobs; var on changed flight; where on>=160; run; This is an INCORRECT answer as it is missing the variable Date

b. proc print data=flights.laguardia; var date on changed flight; where changed>3; run;

11

This is an INCORRECT answer as it does not specify the OBS column as the Date.

c. proc print data=flights.laguardia label; id date; var boarded transferred flight; label boarded='On' transferred='Changed'; where flight='219'; run; This is the CORRECT answer as it specifies the ID column as Date correctly, displays only flight 219 and has the correct labels displayed.

d. proc print flights.laguardia noobs;

id date; var date on changed flight; where flight='219'; run; This is an INCORRECT answer as it does not specify the labels displayed.

3) 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'; - This is an INCORRECT answer

as the expression will not be recognized by SAS. b. where style in 'RANCH' or 'SPLIT' or 'TWOSTORY'; - This is an INCORRECT

answer as values must be specified in parenthesis, separated by commas or spaces and surrounded by quotation marks.

c. where style in (RANCH, SPLIT, TWOSTORY); - This is an INCORRECT answer as values must be specified in parenthesis, separated by commas or spaces and surrounded by quotation marks.

d. where style in ('RANCH', 'SPLIT', 'TWOSTORY'); - This is the CORRECT answer as values must be specified in parenthesis, separated by commas or spaces and surrounded by quotation marks.

4) If you want to sort your data and create a temporary data set named Calc to store the sorted data, which of the following steps should you submit?

a. proc sort data=work.calc out=finance.dividend;

run; This is an INCORRECT answer as the sorting option (by what variable) is not specified.

b. proc sort dividend out=calc; by account; run; This is an INCORRECT answer as the data to be sorted is not specified.

c. proc sort data=finance.dividend out=work.calc; by account; run; This is the CORRECT answer as the input data, output data and variable sorting are correctly defined.

d. proc sort from finance.dividend to calc; by account; run;

12

This is an INCORRECT answer as the output data is not correctly specified.

6) Which of the following statements can you use in a PROC PRINT step to create this output?

a. var month instructors; sum instructors aerclass walkjogrun swim; This statement is correct however, so are the others so this is not the correct ANSWER.

b. var month; sum instructors aerclass walkjogrun swim; This statement is correct however, so are the others so this is not the correct ANSWER.

c. var month instructors aerclass; sum instructors aerclass walkjogrun swim;

This statement is correct however, so are the others so this is not the correct ANSWER. d. all of the above – All of the above statements are correct, so this is the CORRECT answer.

7) 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 PRINT step runs successfully, printing observations in their sorted order. – This is an INCORRECT answer as the observations are not sorted.

b. The PROC SORT step permanently sorts the input data set. – This is an INCORRECT answer as the Proc Sort statement is not correctly written.

c. The PROC SORT step generates errors and stops processing, but the PROC PRINT step runs successfully, printing observations in their original (unsorted) order. – This is the CORRECT answer as PROC SORT is not correctly written but PROC PRINT will continue to display the report unsorted.

d. The PROC SORT step runs successfully, but the PROC PRINT step generates errors and stops processing. – This is an INCORRECT answer as PROC SORT does not run successfully.

8) If you submit the following program, which output does it create? proc sort data=finance.loans out=work.loans; by months amount; run; proc print data=work.loans noobs; var months; sum amount payment; where months<360;

13

run;

a. This is the CORRECT answer as it is correctly sorted by Months, has the sums and the formatting is displayed correctly.

b. This is an INCORRECT answer as the Sums of Amount and Payment are missing dollar signs in front. This should NOT be the case as no option was called to omit special characters (obvious since comma signs are still there).

c. This is an INCORRECT answer as the Months are not sorted.

14

d. This is an INCORRECT answer as it does not have the sum of the “Amount”.

9) Choose the statement below that selects rows in which

• the amount is less than or equal to $5000 • the account is 101-1092 or the rate equals 0.095.

a. where amount <= 5000 and

account='101-1092' or rate = 0.095; This is an INCORRECT answer as rate is changed to 0.095 instead of using a statement to compare the values to the given rate.

b. where (amount le 5000 and account='101-1092') or rate = 0.095; This is an INCORRECT answer as the parentheses are used incorrectly.

c. where amount <= 5000 and (account='101-1092' or rate eq 0.095); This is the CORRECT answer that correctly specifies amounts less than or equal to 5000 and whether the account is 101-1092 or rate equals 0.095.

d. where amount <= 5000 or account='101-1092' and rate = 0.095;

This is an INCORRECT answer as it selects rows where amounts are less than or equal to 5000 or if the account is 101-1092.

Chapter 9 Quiz: 1) Using ODS statements, how many types of output can you generate at once?

a. 1 (only listing output) - This is an INCORRECT answer as you can generate as many ODS outputs as you want as long as you open the ODS destination.

b. 2 - This is an INCORRECT answer as you can generate as many ODS outputs as you want as long as you open the ODS destination.

c. 3 - This is an INCORRECT answer as you can generate as many ODS outputs as you want as long as you open the ODS destination.

d. as many as you want – This is the CORRECT answer as you can generate as many ODS outputs as you want as long as you open the ODS destination.

2) If ODS is set to its default settings, what types of output are created by the code below? ods html file='c:\myhtml.htm';

15

ods pdf file='c:\mypdf.pdf'; a. HTML and PDF – This is an INCORRECT answer as the listing output is also created. b. PDF only – This is an INCORRECT answer as the HTML output is also created. c. HTML, PDF, and listing – This is the CORRECT answer as all three are outputted. d. No output is created because ODS is closed by default. – This is an INCORRECT answer as

outputs are generated by the above given code. 3) What is the purpose of closing the Listing destination in the code shown below? ods listing close; ods html ... ;

a. It conserves system resources. – This is the CORRECT answer as closing the listing destination frees up system memory.

b. It simplifies your program. – This is an INCORRECT answer as adding the listing close option adds more lines to the program.

c. It makes your program compatible with other hardware platforms. – This is an INCORRECT answer as closing the listing destination has no effect on compatibility.

d. It makes your program compatible with previous versions of SAS. - This is an INCORRECT answer as all SAS versions are backwards compatible.

4) When the code shown below is run, what will the file D:\Output\body.html contain? ods html body='d:\output\body.html'; proc print data=work.alpha; run; proc print data=work.beta; run; ods html close;

a. The PROC PRINT output for WorkAlpha. – This is an INCORRECT answer as the output for Work.Beta is also created.

b. The PROC PRINT output for Work.Beta. – This is an INCORRECT answer as the output for Work.Beta is also created.

c. The PROC PRINT output for both WorkAlpha and Work.Beta. – This is the CORRECT answer as the above code outputs both datasets to D:\Output\body.html

d. Nothing. No output will be written to D:\Output\body.html. – This is an INCORRECT answer as an output is created.

A00-201 Practice Exam: 21) 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 – This is the CORRECT answer as the above code sorts the data from sasuser.houses but an output library is not specified, so SAS will default to the temporary library WORK. B. REPORT – This is an INCORRECT answer as it is not a valid temporary library. C. HOUSES – This is an INCORRECT answer as it is not a valid temporary library. D. SASUSER – This is an INCORRECT answer as the default library when one is not specified is WORK.

16

48) The observations in the SAS data set WORK.TEST are ordered by the values of the variable SALARY. The following SAS program is submitted: proc sort data = work.test out = work.testsorted; by name; run; Which one of the following is the result of the SAS program? A. The data set WORK.TEST is stored in ascending order by values of the NAME variable. – This is an INCORRECT answer as the values sorted are in the data set WORK.TESTSORTED. B. The data set WORK.TEST is stored in descending order by values of the NAME variable. – This is an INCORRECT answer as the values sorted are in the data set WORK.TESTSORTED. C. The data set WORK.TESTSORTED is stored in ascending order by values of the NAME variable. – This is the CORRECT answer as WORK.TESTSORTED is the data set sorted by NAME. D. The data set WORK.TESTSORTED is stored in descending order by values of the NAME variable. – This is an INCORRECT answer as the values are not stored in descending order. 49) The SAS data set WORK.AWARDS is listed below: fname points Amy 2 Amy 1 Gerard 3 Wang 3 Wang 1 Wang 2 The following SAS program is submitted: proc sort data = work.awards; by descending fname points; run; Which one of the following represents how the observations are sorted? A. Wang 3 Gerard 3 Wang 2 Amy 2 Wang 1 Amy 1 This is an INCORRECT answer as the fname variable is not sorted. B. Wang 3

17

Wang 2 Wang 1 Gerard 3 Amy 2 Amy 1 This is an INCORRECT answer as the point variable is sorted in ascending order. C. Wang 3 Wang 1 Wang 2 Gerard 3 Amy 2 Amy 1 This is an INCORRECT answer as the point variable is not sorted. D. Wang 1 Wang 2 Wang 3 Gerard 3 Amy 1 Amy 2 This is the CORRECT answer as the fname and point are correctly sorted in descending order. 50) The SAS data set EMPLOYEE_INFO is listed below: IDNumberExpenses 2542 100.00 3612 133.15 2198 234.34 2198 111.12 The following SAS program is submitted: proc sort data = employee_info; <insert BY statement here> run; Which one of the following BY statements completes the program and sorts the data sequentially by ascending expense values within each ascending IDNUMBER value? A. by Expenses IDNumber; - This is an INCORECT answer as it sorts first by expense values rather than IDNumber. B. by IDNumber Expenses; - This is the CORRECT answer as it first sorts by the IDNumber and then by expense values. C. by ascending (IDNumber Expenses); - This is an INCORRECT answer as the parenthesis are not appropriate for this statement. D. by ascending IDNumber ascending Expenses; - This is an INCORRECT answer as the default sorting is by ascending order. 51) The following SAS program is submitted: libnamecompany 'SAS-data-library';

18

proc sort data = company.payroll; by EmployeeIDNumber; run; Write access has been granted to the COMPANY library. Which one of the following represents how the observations are sorted? A. COMPANY.PAYROLL is recreated in sorted order by EmployeeIDNumber. – This is the CORRECT answer as COMPANY.PAYROLL is recreated and sorted by EmployeeIDNumber. B. COMPANY.PAYROLL is stored in original order, and a new data set PAYROLL is created in sorted order by EmployeeIDNumber. – This is an INCORRECT answer as a new data set PAYROLL is NOT created. C. COMPANY.PAYROLL is stored in original order, and a new data set COMPANY.PAYROLLSORTED is created in sorted order by EmployeeIDNumber. – This is an INCORRECT answer as no new data set by the name of COMPANY.PAYROLLSORTED is specified. D. COMPANY.PAYROLL is recreated in sorted order by EmployeeIDNumber, and a new data set PAYROLL is created in sorted order by EmployeeIDNumber. – This is an INCORRECT answer as no new data set by the name of PAYROLL is created. 52) The SAS data set QTR1_REVENUE is listed below: destination revenue YYZ 53634 FRA 62129 FRA 75962 RDU 76254 YYZ 82174 The following SAS program is submitted: proc sort data = qtr1_revenue; by destination descending revenue; run; Which one of the following represents the first observation in the output data set? A. destination revenue YYZ 82174 – This is an INCORRECT answer as destination is sorted in descending order. B. destination revenue YYZ 53634 – This is an INCORRECT answer as destination is sorted in descending order. C. destination revenue FRA 62129 – This is an INCORECT answer as the revenue is sorted in ascending order. D. destination revenue FRA 75962 – This is the CORRECT answer as the destination is sorted in ascending order and revenue in descending order. 53) The SAS data set EMPLOYEE_INFO is listed below: IDNumberExpenses 2542 100.00

19

3612 133.15 2198 234.34 2198 111.12 The following SAS program is submitted: proc sort data = employee_info; <insert BY statement here> run; Which one of the following BY statements completes the program and sorts the data sequentially by descending expense values within each descending IDNUMBER value? A. by descending IDNumber Expenses; - This is an INCORRECT answer as only IDNumber is sorted in descending order. B. by (IDNumber Expenses) descending; - This is an INCORRECT answer as the parenthesis are used incorrectly. C. by IDNumber descending Expenses descending; - This is an INCORRECT answer as the statement descending must be in front of the variable to be sorted. D. by descending IDNumber descending Expenses; - This is the CORRECT answer as IDNumber is first sorted in descending order followed by Expenses. 90) A realtor has two customers. One customer wants to view a list of homes selling for less than $60,000. The other customer wants to view a list of homes selling for greater than $100,000. Assuming the PRICE variable is numeric, which one of the following PRINT procedure steps will select all desired observations? A. proc print data = sasuser.houses; where price lt 60000; where price gt 100000; run; - This is an INCORRECT answer as first the houses less than 60000 are selected and then only houses greater than 100000 selected. In the end only those greater than 100000 will be selected. B. proc print data = sasuser.houses; where price lt 60000 or price gt 100000; run; - This is the CORECT answer that will select all houses less than 60000 and greater than 100000. C. proc print data = sasuser.houses; where price lt 60000 and price gt 100000; run; - This is an INCORRECT answer as it will attempt to select a value that is both less than 60000 and also greater than 100000. D. proc print data = sasuser.houses; where price lt 60000 or where price gt 100000; run; - This is an INCORECT answer as the “where” statement is used more than once in the same line. 93) The following SAS program is submitted:

20

proc sort data = sasuser.houses out = houses; by style; run; proc print data = houses; <insert statement(s) here> run; Click on the Exhibit button to view the report produced. style bedrooms baths price CONDO 2 1.5 80050 3 2.5 79350 4 2.5 127150 2 2.0 110700 RANCH 2 1.0 64000 3 3.0 86650 3 1.0 89100 1 1.0 34550 SPLIT 1 1.0 65850 4 3.0 94450 3 1.5 73650 TWOSTORY 4 3.0 107250 2 1.0 55850 2 1.0 69250 4 2.5 102950 Which of the following SAS statement(s) create(s) the report? A. id style; - This is an INCORRECT answer as it does not list the variables style, bedrooms, baths, price. B. id style; var style bedrooms baths price; - This is an INCORRECT as it doesn’t produce the desired output (Same as C) C. id style; var style bedrooms baths price; - This is an INCORRECTas it doesn’t produce the desired output (Same as B) D. id style; by style; var bedrooms baths price; - This is CORRECT. 106) Which one of the following ODS statement options terminates output being written to an HTML file? A. END – This is an INCORRECT answer as it is not a valid statement to terminate outputs that are being written to an HTML file. B. QUIT – This is an INCORRECT answer as it is not a valid statement to terminate outputs that are being written to an HTML file. C. STOP – This is an INCORRECT answer as it is not a valid statement to terminate outputs that are being written to an HTML file. D. CLOSE – This is the CORRECT answer to terminate outputs being written to an HTML file.

21

A00-211 Practice Exam: 22) The SAS data set PETS is sorted by the variables TYPE and BREED. The following SAS program is submitted: proc print data = pets; var type breed; sum number; run; What is the result? A. The SUM statement produces only a grand total of NUMBER. – This is the CORRECT answer as the SUM statement calculates the grand total of the column NUMBER. B. The SUM statement produces only subtotals of NUMBER for each value of TYPE. – This is an INCORRECT answer as the SUM statement only produces a grand total. C. The SUM statement produces both a grand total of NUMBER and subtotals of NUMBER for each value of TYPE. – This is an INCORRECT answer as the SUM statement only produces a grand total. D. Nothing is produced by the SUM statement; the program fails to execute. – This is an INCORRECT answer as the SUM statement produces a grand total. 31) Given the SAS data set EMPLOYEES: 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 – This is an INCORRECT answer as the statement “wher name like ‘_i%’; selects the employees that have an “i” as the second letter in their name. B. Liu only – This is the CORRECT answer as only Liu has an “i” as the second letter in his name. C. Innis, Jolli, Ellis, and Liu – This is an INCORRECT answer as the statement “wher name like ‘_i%’; selects the employees that have an “i” as the second letter in their name. D. Innis and Ellis only – This is an INCORRECT answer as the statement “wher name like ‘_i%’; selects the employees that have an “i” as the second letter in their name. 48) Given the SAS data set QTR1_REVENUE: destination revenue ------------- ----------

22

YYZ 53634 FRA 62129 FRA 75962 RDU 76254 YYZ 82174 The following SAS program is submitted: proc sort data = qtr1_revenue; by destination descending revenue; run; What is the first observation in the output data set? A. destination revenue YYZ 53634 – This is an INCORRECT answer as destination is sorted in ascending order, not descending. B. destination revenue YYZ 82174 – This is an INCORRECT answer as destination is sorted in ascending order, not descending. C. destination revenue FRA 75962 – This is the CORRECT answer as destination is sorted in ascending order and revenue in descending. D. destination revenue FRA 62129 – This is an INCORRECT answer as revenue is sorted in descending order, not ascending. 52) Given the SAS data set AGES: AGES AGE ------- 9 12 15 The variable AGE contains character values. The following SAS program is submitted: data subset; set ages; where age > 12; run; How many observations are written out to the data set SUBSET? A. 3 – This is an INCORRECT answer as the variable age contains character values, NOT numeric, the “where age>12” statement will not work for character values. B. 1 – This is an INCORRECT answer as the variable age contains character values, NOT numeric, the “where age>12” statement will not work for character values. C. 0 – This is the CORRECT answer as the variable age contains character values, NOT numeric, the “where age>12” statement will not work for character values. D. 2 – This is an INCORRECT answer as the variable age contains character values, NOT numeric, the “where age>12” statement will not work for character values.

23

58) Given the SAS data set WORK.AWARDS: WORK.AWARDS FNAME POINTS MONTH ---------- ---------- ---------- Amy 2 4 Amy 1 7 Gerard 3 3 Wang 3 3 Wang 1 12 Wang 1 8 The following SAS program is submitted: proc sort data = work.awards; by descending fname points; run; How are the observations sorted? A. FNAME POINTS MONTH Amy 2 4 Amy 1 7 Gerard 3 3 Wang 3 3 Wang 1 8 Wang 1 12 This is an INCORRECT answer as fname should be sorted in descending order, NOT ascending. B. FNAME POINTS MONTH Wang 3 3 Wang 1 8 Wang 1 12 Gerard 3 3 Amy 2 4 Amy 1 7 This is an INCORRECT answer as points should be sorted in ascending order, NOT descending. C. FNAME POINTS MONTH Wang 1 12 Wang 1 8 Wang 3 3 Gerard 3 3 Amy 1 7 Amy 2 4 This is the CORRECT answer as fname is sorted in descending order and points in ascending order. D. FNAME POINTS MONTH Wang 3 3 Wang 1 12 Wang 1 8 Gerard 3 3

24

Amy 2 4 Amy 1 7 This is an INCORRECT answer as points should be sorted in ascending order. 62) The following SAS program is submitted, creating the SAS data set ONE: data one; infile 'file specification'; input num char $; run; ONE NUM CHAR ------- -------- 1 23 3 23 1 77 The following SAS program is submitted: proc print data = one; where char = 23; run; What is output? A. No output is generated. – This is the CORRECT answer as char contains character values instead of numeric, so the statement “where char = 23;” would generate an error message with no output. B. NUM CHAR 1 23 3 23 1 77 This is an INCORRECT answer as char contains character values instead of numeric, so the statement “where char = 23;” would generate an error message with no output. C. NUM CHAR 1 77 This is an INCORRECT answer as char contains character values instead of numeric, so the statement “where char = 23;” would generate an error message with no output. D. NUM CHAR 1 23 3 23 This is an INCORRECT answer as char contains character values instead of numeric, so the statement “where char = 23;” would generate an error message with no output. Exercise 2. proc import out=asthmadata file="<…>/Asthma_Ex2.csv" dbms=csv replace; run;

25

ods html path="C:/Users/000110888/Desktop" file="report_Ex2.html"; title1 'Asthma Patients'; title2 'Basic Data Set'; footnote 'Data from Medical Records'; proc sort; by Smoking Patient; run; proc print noobs; var Patient Asthma Age BMI; format BMI 5.1; by Smoking; run; ods html close;

Asthma Patients Basic Data Set

Smoking=heavy smoker

Patient Asthma Age BMI 2 yes 60 23.8

11 yes 45 41.5

Smoking=never Patient Asthma Age BMI

3 no 63 28.1 6 no 26 31.2 9 yes 64 .

10 yes 61 25.3 14 no 65 24.0 15 yes 53 23.2

Smoking=occasionally

Patient Asthma Age BMI 1 no 55 24.5 4 no 25 27.5 5 no 58 31.6 7 yes 61 20.6 8 yes 74 30.7

26

Patient Asthma Age BMI 12 yes 39 . 13 yes 77 23.1 16 no 58 27.4

Data from Medical Records

Exercises for Handout 8: Chapter 1 Quiz:

8) What is the default length for the numeric variable Balance?

a. 5 – This is an INCORRECT answer as numeric values have default lengths of 8. b. 6 – This is an INCORRECT answer as numeric values have default lengths of 8. c. 7 – This is an INCORRECT answer as numeric values have default lengths of 8. d. 8 – This is the CORRECT answer because numeric variables have a default length of 8.

Chapter 2 Quiz:

4) When you specify an engine for a library, you are always specifying

a. the file format for files that are stored in the library. – This is the CORRECT answer because the specified engine for a library determines the format it will be stored in.

b. the version of SAS that you are using. – This is an INCORRECT answer as specifying an engine for the library determines what format it will be stored in.

c. access to other software vendors' files. – This is an INCORRECT answer as specifying an engine for the library determines what format it will be stored in.

d. instructions for creating temporary SAS files. – This is an INCORRECT answer as specifying an engine for the library determines what format it will be stored in.

5) Which statement prints a summary of all the files stored in the library named Area51?

a. proc contents data=area51._all_nods; – This is the CORRECT answer because it has all the correct syntax needed to print a summary of the files stored in library Area51.

b. proc contents data=area51 _all_nods; – This is an INCORRECT answer as it is missing a period in the statement.

c. proc contents data=area51 _all_noobs; – This is an INCORRECT answer as it is missing a period in the statement.

d. proc contents data=area51 _all_.nods; – This is an INCORRECT answer as it is missing a period in the statement.

27

10) What does the following statement do?

libname osiris spss 'c:\myfiles\sasdata\data';

a. defines a library called Spss using the OSIRIS engine – This is an INCORRECT answer as the statement defines a library called “Osiris” with the SPSS engine.

b. defines a library called Osiris using the SPSS engine – This is the CORRECT answer because SAS reads in the characters after libname as first the library name then engine type.

c. defines two libraries called Osiris and Spss using the default engine – This is an INCORRECT answer as only one library can be defined in one statement, also, SPSS is an engine/format type.

d. defines the default library using the OSIRIS and SPSS engines – This is an INCORRECT answer as OSIRIS is NOT a correct engine type and a name for the library must be defined after the libname keyword.

Chapter 5 Quiz:

1) Which SAS statement associates the fileref Crime with the raw data file C:\States\Data\Crime?

a. filename crime 'c:\states\data\crime'; – This is the CORRECT answer because it uses the correct syntax and order to associate the fileref ‘crime’ with the raw data file.

b. filename crime c:\states\data\crime; – This is an INCORRECT answer as it is missing the quotations

around the path filename. c. fileref crime 'c:\states\data\crime'; – This is an INCORRECT answer as the keyword ‘filename’ should

be used here, NOT ‘fileref’. d. filename 'c:\states\data\crime' crime; – This is an INCORRECT answer as the statement is not in the

correct order, ‘crime’ should follow filename for this to correctly associate the fileref with the raw data file.

2) Filerefs remain in effect until …

a. you change them. – This is an INCORRECT answer as they also remain in effect until you cancel them or end your SAS session.

b. you cancel them. – This is an INCORRECT answer as they also remain in effect until you change them or end your SAS session.

c. you end your SAS session. – This is an INCORRECT answer as they also remain in effect until you change or cancel them.

d. all of the above – This is the CORRECT answer because Filerefs remain in effect until you end your SAS session or change/cancel them.

4) Which of the following programs correctly writes the observations from the data set below to a raw data file?

28

a. data _null_; set work.patients; infile 'c:\clinic\patients\referais.dat'; input id 1-4 sex 6 $ age 8-9 height 11-12 weight 14-16 pulse 18-20; run; – This is an INCORRECT answer as this reads in the file ‘referais.dat’ instead of writing out to it. b. data referals.dat; set work.patients; input id 1-4 sex $ 6 age 8-9 height 11-12 weight 14-16 pulse 18-20; run; – This is an INCORRECT answer as it does not specify which raw data file to output. c. data _null_; set work.patients; file c:\clinic\patients\referais.dat; put id 1-4 sex 6 $ age 8-9 height 11-12 weight 14-16 pulse 18-20; run; – This is an INCORRECT answer as the file path should be surrounded by quotations for SAS to read it in correctly. d. data _null_; set work.patients; file 'c:\clinic\patients\referais.dat'; put id 1-4 sex 6 $ age 8-9 height 11-12 weight 14-16 pulse 18-20; run; – This is the CORRECT answer because it uses the correct syntax and SAS statements to write the

observations to the raw data file ‘referais.dat’.

9) Which program correctly reads instream data?

a. data finance.newloan; input datalines; if country='JAPAN'; MonthAvg=amount/12; 1998 US CARS 194324.12 1998 US TRUCKS 142290.30 1998 CANADA CARS 10483.44 1998 CANADA TRUCKS 93543.64 1998 MEXICO CARS 22500.57 1998 MEXICO TRUCKS 10098.88 1998 JAPAN CARS 15066.43

29

1998 JAPAN TRUCKS 40700.34 ; – This is an INCORRECT answer as ‘datalines’ is not specified in this program to read in the data. b. data finance.newloan; input Year 1-4 Country $ 6-11 Vehicle $ 13-18 Amount 20-2E if country='JAPAN'; MonthAvg=amount/12; datalines; run; – This is an INCORRECT answer as ‘datalines’ is not specified in this program to read in the data. c. data finance.newloan; input Year 1-4 Country 6-11 Vehicle 13-18 Amount 20-28; if country='JAPAN'; MonthAvg=amount/12; datalines; 1998 US CARS 194324.12 1998 US TRUCKS 142290.30 1998 CANADA CARS 10483.44 1998 CANADA TRUCKS 93543.64 1998 MEXICO CARS 22500.57 1998 MEXICO TRUCKS 10098.88 1998 JAPAN CARS 15066.43 1998 JAPAN TRUCKS 40700.34 ; – This is an INCORRECT answer as character variables for the country and vehicle are not specified with a ‘$” in the input statement. d. data finance.newloan; input Year 1-4 Country $ 6-11 Vehicle $ 13-18 Amount 20-28; if country='JAPAN'; MonthAvg=amount/12; datalines; 1998 US CARS 194324.12 1998 US TRUCKS 142290.30 1998 CANADA CARS 10483.44 1998 CANADA TRUCKS 93543.64 1998 MEXICO CARS 22500.57 1998 MEXICO TRUCKS 10098.88 1998 JAPAN CARS 15066.43 1998 JAPAN TRUCKS 40700.34 ; – This is the CORRECT answer because it correctly reads in the instream data.

10) Which SAS statement subsets the raw data shown observations in which Sex (in the second field) has a value of F are processed?

30

a. if sex=f; – This is an INCORRECT answer as ‘F’ needs to be surrounded by either quotations or underscores to instruct SAS to process only values with this character value.

b. if sex=F; – This is an INCORRECT answer as ‘F’ needs to be surrounded by either quotations or

underscores to instruct SAS to process only values with this character value. c. if sex=_F_; – This is the CORRECT answer because it correctly instructs SAS to process only

those character values that are ‘F’. d. a or b – This is an INCORRECT answer as ‘F’ needs to be surrounded by either quotations or

underscores to instruct SAS to process only values with this character value. Chapter 7 Quiz:

1) If you don't specify the LIBRARY= option, your formats are stored in Work.Formats, and they exist…

a. only for the current procedure. – This is an INCORRECT answer as they exist until you end the current SAS session.

b. only for the current DATA step. – This is an INCORRECT answer as they exist until you end the current SAS session.

c. only for the current SAS session. – This is the CORRECT answer because formats in the Work library are temporary and only exist in the current SAS session.

d. permanently. – This is an INCORRECT answer as they exist until you end the current SAS session, in order to create a permanent library, you must specify the LIBRARY= option.

2) Which of the following statements will store your formats in a permanent catalog?

a. libname library 'c:\sas\formats\lib'; proc format lib=library ...; – This is the CORRECT answer because b. libname library 'c:\sas\formats\lib'; format lib=library ...; – This is an INCORRECT answer as it is missing the keyword ‘proc’ in the second line. c. library='c:\sas\formats\lib'; proc format library ...; – This is an INCORRECT answer as it is not the correct way to specify a library. d. library='c:\sas\formats\lib'; proc library ...; – This is an INCORRECT answer as it is not the correct way to specify a library.

31

8) You can place the FORMAT statement in either a DATA step or a PROC step. What happens when you place it in a DATA step?

a. You temporarily associate the formats with variables. – This is an INCORRECT answer as formats will be permanently associated with the variables if specified in the DATA step.

b. You permanently associate the formats with variables. – This is the CORRECT answer because the formats will be permanently associated with the variables in the DATA step.

c. You replace the original data with the format labels. – This is an INCORRECT answer as formats will be permanently associated with the variables if specified in the DATA step.

d. You make the formats available to other data sets. – This is an INCORRECT answer as formats will be permanently associated with the variables if specified in the DATA step.

10) Which keyword, when added to the PROC FORMAT statement, will display all the formats in your catalog?

a. CATALOG – This is an INCORRECT answer as it will not display all formats in your catalog when used in the PROC FORMAT statement.

b. LISTFMT – This is an INCORRECT answer as it will not display all formats in your catalog when used in the PROC FORMAT statement.

c. FMTCAT – This is an INCORRECT answer as it will not display all formats in your catalog when used in the PROC FORMAT statement.

d. FMTLIB – This is the CORRECT answer because it will display all formats in your catalog.

A00-201 Practice Exam: 31) The contents of the SAS data set PERM.JAN_SALES are listed below: VARIABLE NAME TYPE idnumcharacter variable sales_datenumeric date value A comma delimited raw data file needs to be created from the PERM.JAN_SALES data set. The SALES_DATE values need to be in a MMDDYY10 form. Which one of the following SAS DATA steps correctly creates this raw data file? A. libname perm 'SAS-data-library'; data_null_; set perm.jan_sales; file 'file-specification' dsd = ','; put idnum sales_date : mmddyy 10.; run; – This is an INCORRECT answer as to specify a comma delimited raw data file, one must use “dlm” for file-specification. B. libname perm 'SAS-data-library'; data_null_; set perm.jan_sales; file 'file-specification' dlm = ','; put idnum sales_date : mmddyy 10.; run; – This is the CORRECT answer because it correctly creates a comma delimited raw data file from PERM.JAN_SALES. C. libname perm 'SAS-data-library'; data_null_; set perm.jan_sales; file 'file-specification'; put idnum sales_date : mmddyy 10. dlm = ','; run;

32

– This is an INCORRECT answer as the file specification for the raw data to be comma delimited must be in the same statement as “file ‘file-specification’”. D. libname perm 'SAS-data-library'; data_null_; set perm.jan_sales; file 'file-specification'; put idnum sales_date : mmddyy 10. dsd = ','; run; - This is an INCORRECT answer as to specify a comma delimited raw data file, one must use “dlm” for file-specification. 32) The contents of the SAS data set named PERM.STUDENTS are listed below: name age Alfred 14 Alice13 Barbara 13 Carol 14 The following SAS program is submitted using the PERM.STUDENTS data set as input: Libnameperm 'SAS-date-library'; data students; set perm.students; file 'file-specification'; put name $15. @5 age 2.; run; Which one of the following represents the values written to the output raw data file? A. ----|----10---|----20---|----30 Alfred 14 Alice 13 Barbara 13 Carol 14 – This is an INCORRECT answer as with the given code, the ages are written out to a raw data file starting with the 5th column, which overlaps with the student names. B. ----|----10---|----20---|----30 Alfr14 Alic13 Barb13a Caro14 – This is the CORRECT answer because the given writes the data set perm.students to a raw data file and erroneously begins the ages at column 5, overwriting some of the longer student names. C. ----|----10---|----20---|----30 Alfr14ed Alic13e Barb13ara Caro14l – This is an INCORRECT answer as with the given code, the ages are written out to a raw data file starting with the 5th column, which overlaps with the student names. Because of this, “Barbara” should read “Barb13a”, with the 13 overwriting the “ar” part of her name. D. ----|----10---|----20---|----30 Alfred 14 Alice 13 Barbara 13 Carol 14

33

– This is an INCORRECT answer as with the given code, the ages are written out to a raw data file starting with the 5th column, which overlaps with the student names. 33) The contents of the raw data file TEAM are listed below: ----|----10---|----20---|----30 Janice 10 Henri 11 Michael 11 Susan 12 The following SAS program is submitted: data group; infile 'team'; input name $15. age 2.; file 'file-specification'; put name $15. =5 age 2.; run; Which one of the following describes the output created? A. a raw data file only – This is an INCORRECT answer as a SAS data set named GROUP is also created. B. a SAS data set named GROUP only – This is an INCORRECT answer as a raw data file is also created. C. a SAS data set named GROUP and a raw data file – This is the CORRECT answer because a data set named GROUP is created in addition to a raw data file. D. No output is generated as the program fails to execute due to errors. – This is an INCORRECT answer as the above given code creates a data set named GROUP as well as a raw data file. 40) The following SAS program is submitted: proc contents data = sasuser.airplanes; run; Which one of the following is produced as output? A. the data portion of every data set in the SASUSER library – This is an INCORRECT answer as only the descriptor portion of the data set SAUSER.AIRPLANES will be outputted. B. the data portion of the data set SASUSER.AIRPLANES only – This is an INCORRECT answer as the above code will only output the descriptor portion of the data set. C. the descriptor portion of every data set in the SASUSER library – This is an INCORRECT answer as only the descriptor portion of the data set SASUSER.AIRPLANES will be outputted. D. the descriptor portion of the data set SASUSER.AIRPLANES only – This is the CORRECT answer because the above code will only output the descriptor portion of the SASUSER.AIRPLANES data set. 41) The following SAS program is submitted: proc datasets lib = sasuser; contents data = class varnum; quit; Which one of the following is the purpose of the VARNUM option? A. to print a list of variable names – This is an INCORRECT answer as VARNUM prints a list of the variables in the order they were created. B. to print the total number of variables – This is an INCORRECT answer as VARNUM prints a list of the variables in the order they were created. C. to print a list of the variables in alphabetic order – This is an INCORRECT answer as VARNUM prints a list of the variables in the order they were created. D. to print a list of the variables in the order they were created – This is the CORRECT answer because VARNUM prints a list of the variables in the order they were created. 42) Which one of the following SAS procedures displays the data portion of a SAS data set?

34

A. PRINT – This is the CORRECT answer because it will correctly display the data portion of a SAS data set. B. FSLIST – This is an INCORRECT answer as it does NOT display the data portion of a SAS data set. C. CONTENTS – This is an INCORRECT answer as it does NOT display the data portion of a SAS data set. D. DATASETS – This is an INCORRECT answer as it does NOT display the data portion of a SAS data set. 43) On which portion(s) of a SAS data set does the PRINT procedure report? A. the data portion only – This is the CORRECT answer because the procedure PRINT will only display the data portion from a SAS data set. B. the descriptor portion only – This is an INCORRECT answer as PRINT will only display the data portion from a SAS data set. C. the descriptor portion and the data portion – This is an INCORRECT answer as PRINT will only display the data portion from a SAS data set. D. neither the data portion nor the descriptor portion – This is an INCORRECT answer as PRINT will only display the data portion from a SAS data set. A00-211 Practice Exam: 35) Which program displays a listing of all data sets in the SASUSER library? A. proc contents lib = sasuser.all; run; – This is an INCORRECT answer as it specifies “lib” instead of “data” to display the data sets. B. proc contents data = sasuser._all_; run; – This is the CORRECT answer because it correctly instructs SAS to display a listing of all data sets in the SASUSER library. C. proc contents data = sasuser.all; run; – This is an INCORRECT answer as the option “all” must be enclosed with underscores. D. proc contents lib = sasuser._all_; run; – This is an INCORRECT answer as it specifies “lib” instead of “data” to display the data sets. 42) A user-defined format has been created using the FORMAT procedure. Where is it stored? A. in a SAS dataset in a permanent SAS data library – This is an INCORRECT answer as the user-defined format is stored in a SAS catalog. B. in a SAS catalog – This is the CORRECT answer because the FORMAT procedure stores user-defined formats in the SAS catalog. C. in an external binary file – This is an INCORRECT answer as the user-defined format is stored in a SAS catalog. D. in a SAS dataset in the WORK library – This is an INCORRECT answer as the user-defined format is stored in a SAS catalog. 66) The following SAS program is submitted: proc contents data = sashelp.class varnum; quit; What does the VARNUM option print? A. a list of the variables in alphabetic order – This is an INCORRECT answer as VARNUM displays a list of the variables in the order they were created. B. a list of variable names – This is an INCORRECT answer as VARNUM also displays the list in the order in which the variables were created. C. the total number of variables – This is an INCORRECT answer as VARNUM displays a list of the variables in the order they were created.

35

D. a list of the variables in the order they were created – This is the CORRECT answer because VARNUM displays a list of the variables in the order they were created. Exercises for Handout 9 material:

A00-201 Practice Exam:

Q91: Answer is D. An order variable can display Rows in a report to be ordered the order variable. Totals are computed for all numeric variables for different values of group variables if group is used. In this case, using order defines style variable.

A is incorrect because order not display option needs to define the variable of style.

B is incorrect because order option needs to define the variable of style.

C is incorrect because order not group option needs to define the variable of style.

Q92: Answer is C. In this case, display option is used to define the variable of style and list every observation which meet the where statement.

A is incorrect because display option not group needs to use to define the variable of style.

B is incorrect because display option not across needs to use to define the variable of price. Across is used to get frequencies for each value of across variables.

D is incorrect because display option not order needs to use to define the variable of style.

Q96: Answer is B. The option group is used to compute statistics (sum, mean, …) for numeric variables for different values of group variables. In this case, we need to get mean of price for different values of style, so group needs to use to define the variable of style.

A is incorrect because group option not order needs to use to define the variable of style.

C is incorrect because group option not across needs to use to define the variable of style.

D is incorrect because group option not display needs to use to define the variable of style.

Q99: Answer is B. In this case, we want to get total values of sales for each value of subsidiary, so group option needs to be used for subsidiary.

A is incorrect because group option not sum needs to use to define the variable of subsidiary.

C is incorrect because group option not order needs to use to define the variable of subsidiary.

D is incorrect because group option not across needs to use to define the variable of subsidiary.

36

Q104: Answer is C. In the format of score doesn’t specify the value of 50.5, so 50.5 still displays as 50.5.

A is incorrect because 50.5 doesn’t belong to 1-50.

B is incorrect because 50.5 doesn’t belong to 51-100.

D is incorrect because 50.5 still displays as 50.5 not missing value.

A00-211 Practice Exam

Q24: Answer is C. In the format of score doesn’t specify the value of 50.5, so 50.5 still displays as 50.5.

A is incorrect because 50.5 doesn’t belong to 1-50.

B is incorrect because 50.5 still displays as 50.5 not missing value.

D is incorrect because 50.5 doesn’t belong to 51-100.

Q25: Answer is D. The option group is used to compute statistics (sum, mean, …) for numeric variables for different values of group variables. In this case, we need to get mean of price for different values of style, so group needs to use to define the variable of style.

A is incorrect because group option needs to use to define the variable of style.

B is incorrect because group option not display needs to use to define the variable of style.

C is incorrect because group option not order needs to use to define the variable of style.

Exercise 3.

proc import out=statesdata file="<…>/states_Ex3.csv" dbms=csv replace; run; proc contents varnum; run; title; option nodate nonumber; proc report data=statesdata nowd headline headskip; define State_Name/ width=20 'State Name'; define State_Abbrev/ spacing=7 width=7 'State Abbrev.'; define Postal_Abbrev/ spacing=10 width=7 'Postal Abbrev.'; define Area/ spacing=10 width=7 'Area (Sq Mi)' format=comma7.0; define Population/ spacing=10 width=10 format=comma10.0; run;

37

State Postal Area

State Name Abbrev. Abbrev. (Sq Mi) Population

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

Alabama Ala. AL 52,423 4,040,587

Alaska Alaska AK 656,424 550,043

Arizona Ariz. AZ 114,006 3,665,228

Arkansas Ark. AR 53,182 2,350,725

California Calif. CA 163,707 29,769,021

Colorado Colo. CO 104,100 3,294,394

Connecticut Conn. CT 5,544 3,287,116

Delaware Del. DE 2,489 666,168

District of Columbia D.C. DC 68 606,900

Florida Fla. FL 65,756 12,937,926

Georgia Ga. GA 59,441 6,478,216

Hawaii Hawaii HI 10,932 1,108,229

Idaho Idaho ID 83,574 1,006,749

Illinois Ill. IL 57,918 11,430,602

Indiana Ind. IN 36,420 5,544,159

Iowa Iowa IA 56,276 2,776,755

Kansas Kans. KS 82,282 2,477,574

Kentucky Ky. KY 40,411 3,685,296

Louisiana La. LA 51,843 4,219,973

Maine Maine ME 35,387 1,227,928

Maryland Md. MD 12,407 4,781,468

Massachusetts Mass. MA 10,555 6,016,425

Michigan Mich. MI 96,705 9,295,297

Minnesota Minn. MN 86,943 4,375,099

Mississippi Miss. MS 48,434 2,573,216

Missouri Mo. MO 69,709 5,117,073

Montana Mont. MT 147,046 799,065

Nebraska Nebr. NE 77,358 1,578,385

38

Nevada Nev. NV 110,567 1,201,833

New Hampshire N.H. NH 9,351 1,109,252

New Jersey N.J. NJ 8,722 7,730,188

New Mexico N.Mex. NM 121,598 1,515,069

New York N.Y. NY 54,471 17,990,455

North Carolina N.C. NC 53,821 6,628,637

North Dakota N.Dak. ND 70,704 638,800

Ohio Ohio OH 44,828 10,847,115

Oklahoma Okla. OK 69,903 3,145,585

Oregon Oreg. OR 98,386 2,842,321

Pennsylvania Pa. PA 46,058 11,881,643

Rhode Island R.I. RI 1,545 1,003,464

South Carolina S.C. SC 32,008 3,468,703

South Dakota S.Dak. SD 77,121 696,004

Tennessee Tenn. TN 42,146 4,877,185

Texas Tex. TX 268,601 16,986,510

Utah Utah UT 84,904 1,722,850

Vermont Vt. VT 9,615 562,758

Virginia Va. VA 42,777 6,187,358

Washington Wash. WA 71,302 4,866,692

West Virginia W.Va. WV 24,231 1,793,477

Wisconsin Wis. WI 65,499 4,891,769

Wyoming Wyo. WY 97,818 453,588