ST521 Final

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

12 The earnings data set contains 1 observation for each of the 12 iterations of the DO loop.

Based on this DATA step, how many observations are in the earnings data set? data earnings; Earned=0; do Count=1 to 12; Earned+(Amount+Earned)*(Rate/12); output; end; run; 0 1 6 12 13

False By default, the FTMTERR system option is in effect. If you want to avoid error messages and continue processing the step when SAS cannot load a format, use the NOFMTERR system option.

By default, the NOFMTERR system option is in effect. If you use a format that SAS cannot load, SAS issues an error message and stops processing the step. True False

False By default, OUTPUT writes to all data sets listed in the DATA statement.

By default, the OUTPUT statement writes to only the first data set listed in the DATA statement. True False

True

By default, user-defined formats are stored in a temporary catalog named work.formats and are deleted at the end of your SAS session. True False

%let rate=23;

Which of the following statements creates a macro variable named rate that has a value of 23? let rate="23"; &let rate=23; %let rate=23; %let rate="23";

False An array can contain either numeric or character elements, but not both.

A single array can contain both numeric and character elements. True False

Location=Dept||'/'||put(SiteNum,4.1); When you use the PUT function, you must specify a format that can write the form of the values. The numeric format 4.1 correctly writes the values of SiteNum.

A typical value for the numeric variable SiteNum is 12.3. Which statement correctly converts the values of SiteNum to character values when creating the variable Location? Location=Dept||'/'||put(SiteNum, $3); Location=Dept||'/'||put(SiteNum,4); Location=Dept||'/'||put(SiteNum,3.1); Location=Dept||'/'||put(SiteNum,4.1);

Yes To eliminate Qtr1-Qtr4 from the narrow data set, use a DROP or KEEP statement in the DATA step or a DROP= or KEEP= option in the DATA statement.

After rotating the wide data set to the narrow data set, are the variables Qtr1-Qtr4 written to the narrow data set by default? work a ID | Q1 | Q2 | Q3 | Q4 120001 | . | . | . | 25 120002 | 15 | 15 | 15 | 15 work b ID | Period | Amount 120001 | Q4 | 25 120002 | Q1 | 15 120002 | Q2 | 15 120002 | Q3 | 15 120002 | Q4 | 15 Yes No

False It might have a list of values.

An iterative DO loop must have a stop value. True False

False The elements do not have to be associated with data set variables. If they are, the variables do not have to be stored in contiguous space.

Array elements must be associated with variables that are stored in contiguous space in a SAS data set. True False

No Match-merging requires that the BY variable be present in all data sets being merged. There is no common variable to each of these data sets.

Can these three data sets be merged in one DATA step? A Hair Makeup Nails Jewelry Shoes B Bows Hairspray Hair Rubber Bands Brush C Hose Socks Anklet Brush Shoes Yes No

b. data work.piedmont(drop=areacode exchange); set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); if areacode='919' and exchange='555' then substr(phone,1,3)='920'; run; When the SUBSTR function is used on the left side on an assignment statement, it replaces characters at a specified position

Due to growth within the 919 area code, the telephone exchange 555 is being reassigned to the 920 area code. The data set clients.piedmont includes the variable Phone, which contains the telephone number in the form 808-555-1234. Which of the following programs correctly changes the values of Phone? a. data work.piedmont(drop=areacode exchange); set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); if areacode='919' and exchange='555' then phone=substr('920',1,3); run; b. data work.piedmont(drop=areacode exchange); set clients.piedmont; Areacode=substr(phone,1,3); Exchange=substr(phone,5,3); if areacode='919' and exchange='555' then substr(phone,1,3)='920'; run;

12 The number of iterations is determined by the DO statement's stop value, which in this case is 12.

During each execution of the following DO loop, the value of Earned is calculated and is added to its previous value. How many times does this DO loop execute? data finance.earnings; Amount=1000; Rate=.075/12; do Month=1 to 12; Earned+(Amount+Earned)*Rate; end; run; 0 1 12 13

do i=1 to 4; In the DO statement, you specify the index variable that represents the values of the array elements. Then specify the start and stop positions of the array elements.

For the program below, select the iterative DO statement that processes all elements in the contrib array. data work.contrib; array contrib{4} qtr1-qtr4; _____________ contrib{i}=contrib{i}*1.25; end; run; do i=4; do i=1 to 4; do until i=4; do while i le 4;

5 The DO loop executes the number of times specified by the stop value. The stop value of this DO loop is the current (first) value of Years, which is 5.

How many times does the DO loop execute for the first iteration of the DATA step? data work.compare(drop=i); set finance.cdrates; Investment=5000; do i=1 to Years; Investment+Rate*Investment; end; run; Finance.cdrates Institution | Rate | Years Superior Bank | .0817 | 5 First Bank | .0814 | 3 Citywide Bank | .0806 | 4 1 5 3 4

the observations from staff that have no match in managers If M=0 and S=1, then only observations from the staff file that do not have a match in the managers file are selected.

If you execute the following DATA step, which observations does the data set bonuses contain? data bonuses; merge managers(in=M) staff(in=S); by EmpID; if M=0 and S=1; run; the observations from staff that have no match in managers the observations from managers that have no match in staff all observations from both managers and staff none of the above

False Format nesting is allowed. Simply enclose the nested format name in square brackets: proc format library=orion.MyFmts; value $extra ' '='Unknown' other=[$country30.]; run;

In the VALUE statement in PROC FORMAT, you cannot nest formats by specifying the format that you are creating. Use a second format as the formatted value. True False

2013 The DO loop shown here executes five times. The initial value for Year is 2008. At the end of the fifth iteration of the DO loop, the value for Year is incremented to 2013. Because this value exceeds the stop value, the DO loop ends. Then, at the bottom of the DATA step, the current values are written to the output data set.

In the data set Invest, what would be the stored value for Year? data invest; do Year=2008 to 2012; Capital+5000; Capital+(Capital*.03); end; run; missing 2008 2012 2013

SELECT PROC SQL requires that lists of items be separated by commas.

In this PROC SQL step, which clause is written incorrectly? proc sql; select Employee_ID Name Dependents from orion.employees where Salary < 50000; quit; FROM WHERE SELECT

TITLE statement

In which location can you not use a format? PUT statement TITLE statement FORMAT= option FORMAT statement

True

Logic errors are often more difficult to detect than syntax errors. True False

False

Logic errors occur when program statements do not conform to the rules of the SAS language. True False

QUIT statement

PROC SQL stops running when it encounters which of the following? semicolon FROM clause RUN statement QUIT statement a second SELECT statement

False The WHERE clause can be used to specify the join and subsetting criteria.

When you are joining tables using PROC SQL, you never use a WHERE clause. True False

(keep=ID Name Amount) The KEEP= data set option specifies the variables to keep in the empinfo.bonuses data set. (KEEP=ID Name Amount)

Suppose the empinfo.bonuses data set contains the variables ID, Name, Office, Manager, Location, and Amount. Specify a data set option in the MERGE statement below to use only the variables ID, Name, and Amount in the data set. data mergedata.emppay; merge sales.reps(rename=(office=OfficeNumber)) empinfo.sales empinfo.bonuses ___________________; by ID; run; (drop=ID Name Amount) (output ID Name Amount) (keep=ID Name Amount) (in=ID Name Amount)

True

The END= option in the SET or INFILE statement creates a variable that acts as an end-of-file indicator. True False

False The END= option creates a variable that can be used to detect the last observation being read. It does not control whether the last observation is executed.

The END= option in the SET or INFILE statement indicates that SAS should process the last observation. True False

c. data ensemble.merged; merge ensemble.spring(rename=(blue=navy)) ensemble.summer; by fabric; run;

The data sets ensemble.spring and ensemble.summer both contain a variable named Blue, and Blue is not the BY variable. Which program prevents the values of the variable Blue from being overwritten when you merge the two data sets? a. data ensemble.merged; merge ensemble.spring(keep=blue) ensemble.summer; by fabric; run; b. data ensemble.merged; merge ensemble.spring(blue=navy) ensemble.summer; by fabric; run; c. data ensemble.merged; merge ensemble.spring(rename=(blue=navy)) ensemble.summer; by fabric; run;

False The values of the BY variable must be sorted or indexed for a match-merge to execute successfully. The ID value 1127 in the donors1 file is out of sequence.

The following program will execute without errors: data work.merged; merge blood.donors1 blood.donors2; by ID; run; Blood.donors1 ID | Type | Units 1104 | O | 16 1129 | A | 48 1127 | A | 50 1129 | A | 57 2486 | B | 63 Blood.donors2 ID | Code | Rate 1104 | 65 | 27 1105 | 63 | 32.25 1129 | 62 | 39.15 2486 | 61 | 45.5 2525 | 64 | 67 True False

State=scan(Address2,2); The SCAN function is used to extract words from a character when you know the order of the words, when their position varies, and when the words are marked by some delimiter. In this case, you do not need to specify delimiters, because the blank and the comma are default delimiters.

The variable Address2 contains values such as Piscataway, NJ. Select the statement that extracts and assigns the two-letter state abbreviation to a new variable named State. State=scan(Address2,2); State=scan(Address2,13,2); State=substr(Address2,2); State=substr(Address2,13,2);

Gender=substr(IDCode,4,1); The SUBSTR function is best used when you know the exact position of the substring to extract from the character value. You specify the variable, the starting position, and the number of characters to extract.

The variable IDCode contains values such as 123FA and 321MB. The fourth character identifies gender. Select the statement that assigns this character code to a new variable named Gender. Gender=scan(IDCode,4); Gender=scan(IDCode,4,1); Gender=substr(IDCode,4); Gender=substr(IDCode,4,1);

New York Because DATA step match-merging overwrites values of same-named variables, the value New York from the last data set merged (dataset3) appears in the output data set.

The variable Location appears in the three data sets represented below. Which value appears in the output data set when the three data sets are merged in the order shown? merge dataset1 dataset2 dataset3; Dataset1 | Dataset2 | Dataset3 Location | Location | Location Florida | Canada | New York Florida Canada New York

putlog Title $quote30.; The value of the width must be wide enough to display the value of the variable as well as the quotation marks.

The variable Title is 22 characters long. One of the values for Title is My House on the Lane. Which of the following statements would provide the full value of the variable in the log if the data included two leading spaces? putlog Title $quote20.; putlog Title $quote22.; putlog Title $quote30.;

True

The variables FmtName, Start, and Label are required in order to create a format from a CNTLIN data set. True False

4 The value in the braces indicates the number of elements in the array. In this case, there are four elements.

What belongs within the braces of this ARRAY statement? array contrib{?} Qtr1-Qtr4; quarter quarter* 1-4 4

HNL:96701 When functions are nested, the innermost function executes first and passes its result to an outer function. The LENGTH function returns the length of the string (13) to the SUBSTR function. The SUBSTR function extracts a nine-character string (13-4) starting from position 1.

What is the new value of Code? Code="HNL:96701-006"; Code=substr(Code,1,length(Code)-4); 96701-006 HNL: HNL:96701 1-006

Messages about macro variable resolution are written to the SAS log.

What is the result of including the following line in your program? options symbolgen; Messages about macro variable resolution are listed in the program output. Messages about macro variable resolution are suppressed in the program output. Messages about macro variable resolution are written to the SAS log. Messages about macro variable resolution are suppressed in the SAS log.

c. formats supplied by SAS work.formats library.formats orion.MyFmts

What is the search order that is used to locate the permanent format given the following OPTIONS statement? options fmtsearch=(orion.MyFmts); a. orion.Myfmts only b. work.formats orion.MyFmts library.formats formats supplied by SAS c. formats supplied by SAS work.formats library.formats orion.MyFmts d. orion.MyFmts Work.formats library.formats formats supplied by SAS

This loop executes infinitely. This loop executes infinitely. Remember that in a DO WHILE loop SAS evaluates the condition at the top of the loop. At the beginning of the first iteration of this loop, the value of X is already greater than 12, so the condition is true. With every subsequent iteration, the value of X increases by 1 and the condition remains true.

What is the value of X at the completion of the DATA step? data test; x=15; do while(x>12); x+1; end; run; 12 15 16 This loop executes infinitely.

3 The index value represents the position of the array element. In this case, the third element is Jul.

What is the value of the index variable that references Jul in the statements below? array quarter{4} Jan Apr Jul Oct; do i=1 to 4; yeargoal=quarter{i}*1.2; end; 1 2 3 4

7+3

What is the value of the macro variable rate after this statement is processed? %let rate=7+3; 10 7+3 _NULL_

True

When a logic error occurs, SAS displays unexpected results. True False

False

When a logic error occurs, SAS writes an error message to the log. True False

4 Use one array element for each variable Qtr1-Qtr4.

When using an array to restructure the data, how many array elements would you use if you wanted the left data set to look like the right data set? work a ID | Q1 | Q2 | Q3 | Q4 120001 | . | . | . | 25 120002 | 15 | 15 | 15 | 15 work b ID | Period | Amount 120001 | Q4 | 25 120002 | Q1 | 15 120002 | Q2 | 15 120002 | Q3 | 15 120002 | Q4 | 15 1 3 4 5

books, last of books, and the values for all the variables in the last observation

When you submit the following program, what is listed in the log? data work.holdings; set work.catalog end=last; if _n_=1 then putlog 'books'; if last then do; putlog 'last of books'; putlog _all_; end; run; books, last of books, and the values for all the variables in the last observation books, last of books, and the values for all the variables in all observations the values of all the variables for the last observation

LIBRARY= The LIBRARY= option enables you to specify a SAS library where the formats that you are creating in the PROC FORMAT step are stored.

Which PROC FORMAT statement option is used to create a permanent format? CNTLIN= FMTLIB= LIBRARY= CNTLOUT=

Day=&sysday;

Which assignment statement sets the value of Day to a text string that contains the day of the week on which the current SAS session began? Day=sysday; Day=&sysday; Day='&sysday'; Day="&sysday";

claims.Policy=accounts.Policy

Which code fragment correctly completes the WHERE clause in this PROC SQL step joining the two tables by Policy? proc sql; select claims.Policy, Claim_Num, Status from insurance.claims insurance.accounts where _____________ = _____________; quit; Policy=Policy claims.Policy=accounts.Policy claims.Policy=insurance.Policy insurance.Policy=insurance.Policy

work b The narrow data set contains a separate observation for each nonmissing quarterly contribution. This enables you to use a simple TABLES statement to calculate the frequency of each value for Period.

Which data set is more appropriate for using PROC FREQ to determine the number of donations made in each of the four quarters? work a ID | Q1 | Q2 | Q3 | Q4 120001 | . | . | . | 25 120002 | 15 | 15 | 15 | 15 work b ID | Period | Amount 120001 | Q4 | 25 120002 | Q1 | 15 120002 | Q2 | 15 120002 | Q3 | 15 120002 | Q4 | 15 work.a work.b

mean(of Var1-Var4) You can use a numbered range list to specify the variables Var1 through Var4. When you use a variable list, you must precede the list with the keyword OF. If you omit the OF, SAS does not interpret the arguments correctly.

Which function calculates the average of the variables Var1, Var2, Var3, and Var4? mean(Var1,Var4) mean(Var1-Var4) mean(of Var1,Var4) mean(of Var1-Var4)

FLOOR The FLOOR function returns the greatest integer less than or equal to the argument.

Which function returns the greatest integer less than or equal to the argument? CEIL INT FLOOR

b. libname mymusic 'C:\Entertainment\Allmusic.xls'; Specify the libref MyMusic and then the filename AllMusic.xls. Include the full path enclosed in quotation marks. Include the file extension when you specify the filename.

Which of the following LIBNAME statements correctly assigns the libref MyMusic to the file AllMusic.xls, which is stored in the Entertainment directory of the C: drive on the Windows operating environment? a. libname mymusic 'Allmusic.xls'; b. libname mymusic 'C:\Entertainment\Allmusic.xls'; c. libname mymusic 'C:\Entertainment\Allmusic'; d. libname mymusic 'C:\Entertainment\Allmusic' filetype='excel';

IN= When you combine two data sets, you can use IN= data set options to track which of the original data sets contributes to each observation in the new data set.

Which of the following data set options can be added to the MERGE statement to help identify data set contributors (that is, identify the matches)? OBS= IN= RENAME= MATCHES=

put(Level,3.) The PUT function explicitly converts numeric values to character values. You specify the keyword PUT followed by the variable name and then the format. The variable name and format are enclosed in parentheses and separated by a comma.

Which of the following functions can convert the values of the numeric variable Level to character values? put(Level,3.) input(3.,Level) put(3.,Level) input(Level,3.)

input(Base,comma10.2) The INPUT function explicitly converts character values to numeric values. You specify the keyword INPUT followed by the variable name and then the INFORMAT. The variable name and INFORMAT are enclosed in parentheses and separated by a comma. A numeric INFORMAT is needed for character-to-numeric conversions.

Which of the following functions converts the character values of Base to numeric values? put(comma10.2,Base) put(Base,comma10.2) input(Base,comma10.2) input(comma10.2, Base)

Write all the logic errors to the log.

Which of the following is not a task of the PUTLOG statement? Write text to the log. Write formatted values to the log. Write all the logic errors to the log. Write the values of all the variables to the log.

work b Narrow data sets typically have multiple observations, with a small amount of data per entity. A narrow data set might or might not contain missing values.

Which of these data sets could be described as a narrow data set? work a ID | Q1 | Q2 | Q3 | Q4 120001 | . | . | . | 25 120002 | 15 | 15 | 15 | 15 work b ID | Period | Amount 120001 | Q4 | 25 120002 | Q1 | 15 120002 | Q2 | 15 120002 | Q3 | 15 120002 | Q4 | 15 work.a work.b

PROC CATALOG

Which procedure enables management of a SAS catalog? PROC COPY PROC CATMOD PROC CATALOG PROC CONTENTS

Only character variables can be created. Either numeric or character variables can be created.

Which statement below is false regarding the use of arrays to create variables? The variables are added to the program data vector during the compilation of the DATA step. You do not need to specify the array elements in the ARRAY statement. By default, all character variables are assigned a length of eight. Only character variables can be created.

d. The output control data set contains information that describes formats. It is the data set that is created with the CNTLOUT= option in the PROC FORMAT statement.

Which statement best describes the purpose of the output control data set? a. The output control data set enables you to output one value for one observation that contains the information about the format. b. The output control data set enables you to output formats without writing VALUE statement in the PROC FORMAT step. c. The output control data set contains information that describes formats. It is the data set that is created with the CNTLIN= option in the PROC FORMAT statement. d. The output control data set contains information that describes formats. It is the data set that is created with the CNTLOUT= option in the PROC FORMAT statement.

A SAS macro variable is independent of a SAS data set and contains a text string. The value of the macro variable remains constant until you change it.

Which statement correctly defines a SAS macro variable? A SAS macro variable is a data set variable whose value depends on the observation that is being processed. A SAS macro variable is independent of a SAS data set and contains a text string. The value of the macro variable remains constant until you change it.

It is an executable statement. An ARRAY statement is not an executable statement. It merely defines an array.

Which statement is false regarding an ARRAY statement? It is an executable statement. It can be used to create variables. It must contain either all numeric or all character elements. It must be used to define an array before the array name can be referenced.

Each DO loop must use the same increment value When you nest DO loops, you must use different index variables for each loop, and you must be certain that each DO statement has a corresponding END statement. Each DO loop can use different increment values.

Which statement is false regarding nested DO loops? Each DO statement must have a corresponding END statement. Each DO loop must have its own index variable. Each DO loop must use the same increment value. Each DO loop can contain iterated SAS statements.

When using the MERGE statement with the BY statement, the data must be sorted or indexed on the BY variables. With match-merging, each input data set must first be sorted on the values of the BY variable (or variables) or have an appropriate index.

Which statement is true concerning match-merging? The MERGE statement must refer to permanent data sets. The variables in the BY statement can be in only one of the data sets. Only two data sets can be specified in the MERGE statement. When using the MERGE statement with the BY statement, the data must be sorted or indexed on the BY variables.

d. The FMTLIB option in PROC FORMAT prints information about all formats in the catalog that is specified in the LIBRARY= option.

Which statement is true concerning the FMTLIB option in PROC FORMAT? a. The FMTLIB option in PROC FORMAT prints information about all permanent formats in your SAS session. b. The FMTLIB option in PROC FORMAT prints information about all of the formats in the work.formats catalog. c. The FMTLIB option in PROC FORMAT prints information about all of the formats in the LIBRARY.FORMATS option. d. The FMTLIB option in PROC FORMAT prints information about all formats in the catalog that is specified in the LIBRARY= option.

c. if yellow=1 and purple=1 and pink=1; The subsetting IF statement specifies all three IN= variables in the IF condition. The AND operator joins expressions in the condition. You can also write the IF statement as follows: if yellow and purple and pink;

Which subsetting IF statement selects observations only if all three input data sets contribute to the current observation? data merged.flowers; merge spring.roses(rename=(red=BrickRed) in=yellow) spring.lilacs(in=purple) spring.petunias(in=pink); by ID; _________________________ run; a. if yellow=1 and purple=1 or pink=1; b. if yellow=0 or purple=0 or pink=0; c. if yellow=1 and purple=1 and pink=1; d. if yellow=1 or purple=1 and pink=0;

Yes

Will this PROC SQL step run? proc sql; select SaleDate from sales where SaleAmt>500; quit; Sales SaleDate | SaleAmt 17257 | 498.49 17259 | 946.5 17259 | 994.97 Yes No

b. data work.bookcase; set furn.bookcase; if find(finish,'walnut','I')>0; run; When you use the I modifier in the FIND function to make the search case-insensitive, you must enclose it in quotation marks.

Within the data set furn.bookcase, the variable Finish contains values such as ash, cherry, teak, and matte-black. Which of the following creates a subset of the data in which the values of Finish contain the string walnut? Make the search for the string case-insensitive. a. data work.bookcase; set furn.bookcase; if find(finish,'walnut',I); run; b. data work.bookcase; set furn.bookcase; if find(finish,'walnut','I')>0; run;


Set pelajaran terkait

Statistics for Social Workers Chapter 2 Frequency Distribution/ Graphs

View Set

Nature of Science statements 11-20

View Set

CTS 110 Network Essentials Module 1 to Module 13 Quiz for Network+ Guide to Networks 8th Edition

View Set

Engine size and performance measurements

View Set

UFC1 - Chapter 4 Activity based Costing

View Set