Base SAS Programming Quiz Flashcards

1
Q

How many steps does the program contain?

data national;
set sashelp.baseball;
BatAvg = nHits/nAtBat;
run;

proc contents data=national;
run;

proc print data=national;
run;

proc means data=national;
var BatAvg;
run;

A

a. one
b. two
c. four - correct
d. eight

Explain: RUN, QUIT, DATA, and PROC statements function as step boundaries, which determine when SAS statements take effect and indicate the end of the current step or the beginning of a new step.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Running a SAS program can create which of the following?

 a. log
 b. output data
 c. results
 d. all of the above
A

a. log
b. output data
c. results
d. all of the above - correct

Explain: A SAS program always creates a log. A program can create output data and results as well, depending on the steps included.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which of the following is a SAS syntax requirement?

 a. Begin each statement in column one.
 b. Put only one statement on each line.
 c. Separate each step with a line space.
 d. End each statement with a semicolon.
A

a. Begin each statement in column one.
b. Put only one statement on each line.
c. Separate each step with a line space.
d. End each statement with a semicolon. - correct

Explain: All SAS statements must end with a semicolon, but they are free-format. You can begin or end them anywhere, separate steps with line spaces, and optionally end steps with a RUN statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following steps is typically used to generate reports and graphs?

 a. DATA
 b. PROC
 c. REPORT
 d. RUN
A

a. DATA
b. PROC - correct
c. REPORT
d. RUN

Explain: PROC steps are typically used to process SAS data sets (that is, generate reports, graphs, and statistics).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
Does this comment contain syntax errors?
 /*
Report created for budget
presentation; revised October 15.
  */
proc print data=work.newloan;
run;
A

a. No. The comment is correctly specified. - correct
b. Yes. Every comment line must end with a semicolon.
c. Yes. The comment is on more than one line.
d. Yes. There is a semicolon in the middle of the comment.

Explain: A block comment can contain semicolons and unbalanced quotation marks, can appear anywhere, and doesn’t need a semicolon at the end.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What result would you expect from submitting this step?
proc print data=work.newsalesemps
run;

A

b. an error message in the log

Explain: There is a missing semicolon following the data set name. When this step runs, SAS will interpret the word run as an option in the PROC PRINT statement (because of the missing semicolon). As a result, the PROC PRINT step will not execute and an error message will be displayed in the log.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What happens if you submit the following program?
porc print data=work.newsalesemps;
run;

A

b. SAS assumes that PROC is misspelled and executes the step.- correct

Explain: The log will indicate that SAS assumed that the keyword PROC was misspelled, corrected it temporarily, and executed the PROC step.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
This program contains a syntax error because National is in different cases.
data national;
    set sashelp.baseball;
    BatAvg=nHits/nAtBat;
run;

proc means data=NATIONAL;
var BatAvg;
run;

A

b. False - correct

Explain: Case does not matter in unquoted values, so in this case, the data set name can be specified in any case.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How many statements does this program contain?
*Create a cars report;

title “European Cars Priced Over 30K”;
footnote “Internal Use Only”;

proc print data=sashelp.cars;
    where Origin='Europe'
          and MSRP>30000;
    var Make Model Type
        Mpg_City Mpg_Highway;
run;
A

c. seven - correct

Explain: This program contains seven statements (seven semicolons): comment, TITLE, FOOTNOTE, PROC, WHERE (two lines), VAR (two lines), and RUN.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which of the following is not a SAS programming interface?

 a. SAS Enterprise Guide
 b. SAS Manager
 c. SAS Studio
 d. SAS windowing environment
A

b. SAS Manager - correct

Explain: The programming interfaces include SAS Enterprise Guide (client application), SAS Studio (web-based), and SAS windowing environment. There is not an interface or product named SAS Manager.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
In this PROC CONTENTS output, what is the default length of the Birth_Date column?
#	Variable	                    Type
4	Birth_Date	             Num
3	Customer_Address    Char
1	Customer_ID	             Num
2	Customer_Name	     Char
A

b. 8 bytes - correct

Explain: Birth_Date is a numeric column, and all numeric columns in SAS are 8 bytes by default.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which LIBNAME statement has the correct syntax?

a. libname reports “filepath/workshop”;
b. libname orion filepath/workshop;
c. libname 3456a “filepath/workshop”;

A

a. libname reports “filepath/workshop”; - correct

Explain: The libref must start with a letter or an underscore and contain eight characters maximum. The path must also be in quotation marks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which of the following tables is available at the beginning of a new SAS session?

a. sales
b. work.newsalesemps
c. sashelp.class

A

c. sashelp.class - correct

Explain: The Sashelp library contains sample and resource tables provided by SAS. The library is automatically available when SAS starts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What type of values are represented with a period when missing?

What type of values are represented with a space when missing?

A

Missing numeric values are represented with a period,

Missing character values are represented with a period,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which statement about SAS dates is false?

a. A SAS date is one of three SAS column types: numeric, character, and date.
b. SAS dates represent the number of days from January 1, 1960.
c. SAS date values can be positive or negative.
d. SAS date values can be used in calculations.

A

a. A SAS date is one of three SAS column types: numeric, character, and date. - correct

Explain: SAS columns are either character or numeric. SAS date values are numeric values that represent the number of days before or after January 1, 1960.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which LIBNAME statement has the correct syntax for reading a Microsoft Excel file?

a. libname excel “filepath/myexcelfile”;
b. libname mydata xlsx “filepath/myexcelfile”;
c. libname mydata xlsx “filepath/field_data.xlsx”;

A

c. libname mydata xlsx “filepath/field_data.xlsx”; - correct

Explain: After the libref, the XLSX engine is specified. The full path to the Excel file, including the .xlsx file extension, must be provided in quotation marks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Which library name (libref) is valid?

a. 2010Car
b. car/2010
c. car2010
d. cars_2010

A

c. car2010 - correct

Explain: This libref follows all three rules for valid librefs. A libref must have a length of one to eight characters, and must begin with a letter or underscore. The remaining characters must be letters, numbers, or underscores.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

To disassociate a libref that you previously assigned, you can use the UNASSIGN option in the LIBNAME statement.

a. True
b. False

A

b. False - correct

Explain: Use the CLEAR option in the LIBNAME statement to disassociate an assigned libref.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does this code do?
proc import datafile=”d:/collect817/bird_count.csv”
dbms=csv out=bird817 replace;
run;

a. It creates a SAS data set named bird817 in the work library from the CSV file bird_count and replaces bird817 whenever the CSV file is updated.
b. It creates a SAS data set named bird817 in the work library from the CSV file bird_count.
c. It uses the CSV engine to directly read the data file bird_count.csv.

A

b. It creates a SAS data set named bird817 in the work library from the CSV file bird_count. - correct

Explain: This PROC IMPORT step creates a SAS data set from a CSV file. When the code runs, it replaces the SAS data set if it already exists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q
In which portion of a SAS data set are the following found?
name of the data set
type of the column Salary
creation date of the data set
 a.  descriptor portion
 b.  data portion
A

a. descriptor portion - correct

Explain: The descriptor portion of a SAS table includes the table metadata.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Based on the following program and data, how many rows will be included in the payment table?

proc sort data=payment dupout=dups nodupkey;
by ID;
run;

ID	Amount
A	$997.54
A	$833.88
B	$879.05
C	$894.77
C	$894.77
C	$998.26
A

a. 1
b. 3 - correct
c. 5
d. 6

Explain: The NODUPKEY option keeps the first row for each unique value of ID, which includes A, B and C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Which of the following FORMAT statements was used to create this output?
Obs Order_ID Order_Date Delivery_Date
1 1230058123 11JAN07 01/11/07
2 1230080101 15JAN07 01/19/07
3 1230106883 20JAN07 01/22/07

a. format Order_Date date9. Delivery_Date mmddyy8.;
b. format Order_Date date7. Delivery_Date mmddyy8.;
c. format Order_Date ddmmmyy. Delivery_Date mmddyy8.;
d. format Order_Date monyy7. Delivery_Date mmddyy8.;

A

b. format Order_Date date7. Delivery_Date mmddyy8.; - correct

Explain: The DATE7. format displays a two-digit day, three-letter month abbreviation, and two-digit year. The MMDDYY8. format displays a two-digit month, day, and year, separated by slashes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

The format name must include a period delimiter in the FORMAT statement.

a. True
b. False

A

a. True - correct

Explain: The period is a required syntax element in a format name within a FORMAT statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Which row or rows will be selected by the following WHERE statement?
where Job_Title like “Sales%”;
Obs Last_Name First_Name Country Job_Title
1 Wu Christine AU Sales Rep I
2 Stone Kimiko AU Sales Manager
3 Hoffman Fred AU Insurance Sales

a. row 1
b. row 2
c. row 3
d. rows 1 and 2
e. all rows

A

d. rows 1 and 2 - correct

Explain: This WHERE statement returns rows that contain Sales with any number of additional characters after Sales because of the position of the percent sign.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q
Which statement about this PROC SORT step is true?
proc sort data=orion.staff;
          out=work.staff;
    by descending Salary Manager_ID;
run;

a. The sorted table overwrites the input table.
b. The rows are sorted by Salary in descending order, and then by Manager_ID in descending order.
c. A semicolon should not appear after the input data set name.
d. The sorted table contains only the columns specified in the BY statement.

A

c. A semicolon should not appear after the input data set name. - correct

Explain: This PROC SORT step has a syntax error: a semicolon in the middle of the PROC SORT statement. If you correct this syntax error, this step sorts orion.staff by Salary in descending order and by Manager_ID in ascending order. The step then creates the temporary data set staff that contains the sorted rows and all columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Which of the following statements selects from a table only those rows where the value of the column Style is RANCH, SPLIT, or TWOSTORY?

a. where Style=’RANCH’ or ‘SPLIT’ or ‘TWOSTORY’;
b. where Style in ‘RANCH’ or ‘SPLIT’ or ‘TWOSTORY’;
c. where Style in (RANCH, SPLIT, TWOSTORY);
d. where Style in (‘RANCH’, ‘SPLIT’, ‘TWOSTORY’);

A

d. where Style in (‘RANCH’, ‘SPLIT’, ‘TWOSTORY’); - correct

Explain: In the WHERE statement, the IN operator enables you to select rows based on several values. You specify values in parentheses and separate them with spaces or commas. Character values must be enclosed in quotation marks and must be in the same case as in the data set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

Which of the following statements selects rows in which Amount is less than or equal to $5,000 or Rate equals 0.095?

a. where amount <= 5000 or rate=0.095;
b. where amount le 5000 or rate=0.095;
c. where amount <= 5000 or rate eq 0.095;
d. all of the above

A

d. all of the above - correct

Explain: All of the statements shown here select rows in which Amount is less than or equal to $5000 or Rate equals 0.095.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

Which statement creates the macro variable flower and assigns the value Plumeria?

a. %let flower=Plumeria;
b. %let flower=”Plumeria”;
c. %let &flower=Plumeria;
d. %let &flower=”Plumeria”;

A

a. %let flower=Plumeria; - correct

Explain: In the %LET statement, the name of the macro variable is followed by an equal sign and the unquoted value. The ampersand is added when you use the macro variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

Which statement in a PROC MEANS step lets you specify the numeric columns to analyze?

a. TABLES
b. VARS
c. VAR
d. KEEP=

A

c. VAR - correct

Explain: You use the VAR statement to specify the numeric columns to analyze in PROC MEANS. If you don’t specify the VAR statement, all numeric columns are analyzed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

Suppose you have a table that includes flower sales to all your retail outlets. You want to see the distinct values of Flower_Type with a count and percentage for each. Which procedure would you use?

A

d. FREQ - correct

Explain: PROC FREQ output includes the distinct values for the column, as well as a frequency count, percent, cumulative frequency, and cumulative percent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

In which phase does the DATA step check for syntax errors?

a. compilation
b. execution

A

a. compilation - correct

Explain: Checking for syntax errors is the first step in the compilation phase.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

Which statement is used to read a SAS data set in a DATA step?

A

c. SET statement - correct

Explain: The SET statement indicates the table that will be read. The DATA statement indicates the table that will be created or updated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

To process an Excel file with the DATA step, you must first create a copy of the data as a SAS table.

a. True
b. False

A

b. False - correct

Explain: You can use the XLSX LIBNAME engine to read an Excel worksheet directly and process the data with the DATA step.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q
What is the name of the ouput data set in the program below?
data work.us;
    set orion.sales;
    where Country='US';
run;

a. work.us
b. orion.sales
c. Country
d. sales

A

a. work.us - correct

Explain: The output table is listed in the DATA statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

The data set orion.sales contains nine columns. Given this DATA step, how many columns does work.comp have?
data work.comp;
set orion.sales;
keep employee_id status job_title salary;
run;

a. four
b. nine
c. five

A

a. four - correct

Explain: Only the four columns listed in the KEEP statement are written to the work.comp table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

iven the assignment statement below, what is the value of AvgExp for the observation that is shown?
AvgExp=mean(Exp1, Exp2, Exp3, Exp4);

Exp1 Exp2 Exp3 Exp4
10 . 5 9
a. 6
b. 8
c. . (missing value)
d. The statement generates a syntax error.

A

b. 8 - correct

Explain: The MEAN function ignores missing values, so the calculation is (10+5+9)/3=8.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Which of the following SAS functions returns a number from 1 to 12?

a. YEAR(SAS-date-value)
b. MONTH(SAS-date-value)
c. WEEKDAY(SAS-date-value)
d. none of the above

A

b. MONTH(SAS-date-value) - correct

Explain: The MONTH function returns the month number (1-12) extracted from a SAS date value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

In the program below, what is the value of Credit if Country is ‘au’?
data work.bonus;
set orion.sales;
if Country=’US’ then Credit=300;
else if Country=’AU’ then Credit=500;
else Credit=0;
run;

a. 300
b. 500
c. 0
d. missing

A

c. 0 - correct

Explain: The character conditions are case sensitive. The first two IF conditions are false. Therefore, the final ELSE statement assigns Credit a value of zero.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

What is the length of the Car_Type column created in this program?
data car_type;
set sashelp.cars;
if msrp>80000 then car_type=”luxury”;
else car_type=”regular”;
length car_type $ 8;
run;

a. 6
b. 7
c. 8

A

a. 6 - correct

Explain: When the DATA step is compiled, the first mention of Car_Type determines the column name, type, and length. The length is determined by the value in the assignment statement. The value luxury has six characters, so the length is 6.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

Use a DO group in a DATA step when you want to execute multiple statements for a true IF-THEN expression.

a. True
b. False

A

a. True - correct

Explain: To execute more that one statement if a condition is true, you must use IF-THEN/DO groups.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q
When you run this program, which title or titles appear in the final PROC PRINT results?
title1 'The First Line';
title2 'The Second Line';
proc print data=sales;
run;
title2 'The Next Line';
proc print data=sales;
run;
title 'The Top Line';
proc print data=sales;
run;

a. The Top Line
b. The Top Line
The Next Line
c. The Top Line
The Second Line
d. The Top Line
The First Line
The Next Line

A

a. The Top Line - correct

Explain: TITLE is the same as TITLE1. The TITLE statement for the last PROC PRINT step cancels all the higher TITLEn statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q
Which statement substitutes the value of the macro variable Year in the footnote?
%let Year=2018;

a. footnote ‘year Sales’;
b. footnote ‘&year Sales’;
c. footnote “%year Sales”;
d. footnote “&year Sales”;

A

d. footnote “&year Sales”; - correct

Explain: To reference a macro variable, use the & followed by the name of the macro variable (for example, &YEAR). The macro variable must be in double quotation marks in the FOOTNOTE statement in order for the value to be substituted. If single quotation marks are used, the value is not substituted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q
Which statement is true based on the given program?
data baseball2;
    set sashelp.baseball;
    BatAvg=CrHits/CrAtBat;
    label BatAvg="Batting Average";
run;

proc print data=baseball2;
var Name Team BatAvg;
run;

proc means data=baseball2;
    var BatAvg;
    class Team;
run;

a. The column BatAvg will have a permanent label in the sashelp.baseball data set.
b. The label for BatAvg will appear in the PROC PRINT report.
c. The label for BatAvg will appear in the PROC MEANS report.
d. The label for BatAvg will appear in both reports.

A

c. The label for BatAvg will appear in the PROC MEANS report. - correct

Explain: The label will appear in the PROC MEANS report. The label will not appear in the PROC PRINT report because the LABEL option is missing in the PROC PRINT statement. The output table work.baseball2 (not the input table sashelp.baseball) contains a permanent label for BatAvg.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

Which statement is true regarding a BY statement in a reporting procedure such as PROC PRINT?

a. The BY statement is responsible for sorting the table.
b. Only one column can be specified in the BY statement.
c. The BY statement groups the report by the specified columns.
d. The BY statement must be the first statement after the PROC statement.

A

c. The BY statement groups the report by the specified columns. - correct

Explain: The BY statement in a reporting procedure is responsible for grouping the report by the specified columns. One or multiple columns can be in the BY statement. The BY statement can be placed in any order within a PROC step. The BY statement in PROC SORT is responsible for sorting the table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

Which statement is false concerning the FREQ procedure?

a. The NOPROCTITLE option can be placed in the PROC FREQ statement to remove the procedure title The FREQ Procedure.
b. The ORDER=FREQ option can be placed in the PROC FREQ statement to display the column values in descending frequency count order.
c. The PLOTS= option can be placed in the TABLES statement after the forward slash to create bar charts based on counts or percentages.
d. The OUT= option can be placed in the TABLES statement after the forward slash to create a table containing counts and percentages.

A

a. The NOPROCTITLE option can be placed in the PROC FREQ statement to remove the procedure title The FREQ Procedure. - correct

Explain: The NOPROCTITLE option goes in a global ODS statement to remove the procedure title.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

Which PROC FREQ step creates the results shown here?
Number of Variable Levels
Variable Levels
Region 10

Region	Frequency	Percent
Africa	    56                  14.18
Asia	            14                   3.54
Canada	    37                  9.37
Central America/Caribbean	32    8.10

a. proc freq data=sashelp.shoes;
tables Region nocum;
run;

b. proc freq data=sashelp.shoes levels;
tables Region / nocum;
run;

c. proc freq data=sashelp.shoes nlevels;
tables Region / nocum;
run;

d. proc freq data=sashelp.shoes / levels;
tables Region nocum;
run;

A

c. proc freq data=sashelp.shoes nlevels;
tables Region / nocum;
run; - correct

Explain: The NLEVELS option in the PROC MEANS statement creates a table displaying the number of levels for all TABLES columns. The NOCUM option in the TABLES statement, which goes after the forward slash, suppresses the display of cumulative frequencies and cumulative percentages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

Which statement is true concerning the MEANS procedure?

a. The VAR statement is required and identifies the analysis columns.
b. The WAYS statement specifies the number of ways to make unique combinations of class columns.
c. The MAXDEC= option is used in the VAR statement to specify the number of decimal places for the statistics.
d. The COUNT and FREQ columns are automatically included in the output summary table that is produced by the OUT= option of the OUTPUT statement.

A

b. The WAYS statement specifies the number of ways to make unique combinations of class columns. - correct

Explain: The WAYS statement specifies the number of ways to make unique combinations of class variables. The VAR statement is not required. The MAXDEC= option goes in the PROC MEANS statement. FREQ and TYPE are automatically included in the output summary table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q
An input table must be pre-sorted by the column(s) listed in the CLASS statement of a PROC MEANS step.
proc means data=sashelp.heart;
    var Cholesterol;
    class Weight_Status;
run;

a. True
b. False

A

b. False - correct

Explain: The input table does not have to be pre-sorted by the column(s) in the CLASS statement of the PROC MEANS step. If a BY statement is used instead of a CLASS statement, the columns need to be sorted.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

Which statement from PROC MEANS contains valid syntax for creating a summary output table?

a. out=work.summary mean;
b. out work.summary mean(Weight)=TotW;
c. output out work.summary Weight=TotW;
d. output out=work.summary mean(Weight)=TotW;

A

d. output out=work.summary mean(Weight)=TotW; - correct

Explain: The OUTPUT statement writes statistics to an output table. The OUT= option names the output table. Statistic(input-variable)=output-variable can be specified in the OUTPUT statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

Which statement is false concerning the options for the PROC EXPORT statement?

a. The DATA= option identifies the input SAS table.
b. The REPLACE option specifies to overwrite an existing file.
c. The DBMS= option specifies the database identifier for the type of file being created.
d. The OUT= option specifies the path and file name of the external data file being created.

A

d. The OUT= option specifies the path and file name of the external data file being created. - correct

Explain: The OUTFILE= (not OUT=) option specifies the path and filename of the external data file being created.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

Which PROC EXPORT step contains valid syntax?
a. proc export outfile=”c:\temp\cars.txt” tab
data=sashelp.cars replace; run;

b. proc export data=sashelp.cars dbms=csv
outfile=”c:\temp\cars.csv”; run;

c. proc export data=sashelp.class; dbms=csv;
outfile=”c:\temp\cars.csv”; run;

d. proc export dbms=tab data=sashelp.cars replace=yes
outfile=”c:\temp\cars.txt”; run;

A

b. proc export data=sashelp.cars dbms=csv
outfile=”c:\temp\cars.csv”; run; - correct

Explain: DATA=, DBMS=, and OUTFILE= are valid PROC EXPORT options. For answer a, DBMS= is missing in front of TAB. For answer c, there shouldn’t be semicolons after each option. For answer d, =YES is not valid after REPLACE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

What does the following program create?
libname sales xlsx ‘c:\mydata\midyear.xlsx’;

data sales.q1_2018; 
    set sasdata.qtr1_2018; 
run; 
data sales.q2_2018; 
    set sasdata.qtr2_2018; 
run; 

a. two SAS tables: sales.q1_2018 and sales.q2_2018
b. two Excel workbooks: sales.q1_2018 and sales.q2_2018
c. two worksheets in the Excel workbook: midyear: q1_2018 and q2_2018
d. two worksheets in the Excel workbook: sales: q1_2018 and q2_2018

A

c. two worksheets in the Excel workbook: midyear: q1_2018 and q2_2018 - correct

Explain: The LIBNAME statement specifies the Excel workbook midyear. The DATA statements create the worksheets q1_2018 and q2_2018 within the workbook midyear. The library reference of sales is what links the LIBNAME and DATA statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

Which statement disassociates the sales libref?
libname sales xlsx ‘c:\mydata\midyear.xlsx’;

a. libname sales end;
b. libname sales clear;
c. libname sales close;
d. libname sales disassociate;

A

b. libname sales clear; - correct

Explain: The CLEAR option in the LIBNAME statement disassociates one or more currently assigned librefs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

What type of output file does this program create?
libname mylib xlsx “s:/workshop/output/test.xlsx”;

data class_list;
set sashelp.class;
run;

a. SAS table
b. delimited file
c. Microsoft Excel XLS file
d. Microsoft Excel XLSX file

A

a. SAS table - correct

Explain: The DATA statement references class_list. A libref is not specified, so the work library is assumed. Work.class_list is a temporary SAS table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

Which of these programs creates a Microsoft Excel file?
a. ods excel file=”s:/workshop/output/class.xlsx”;
proc print data=sashelp.class;
run;
ods excel close;

b. libname mylib xlsx “s:/workshop/output/class.xlsx”;
data mylib.class_list;
set sashelp.class;
run;

c. both
d. neither

A

c. both - correct

Explain: Both ODS EXCEL and the LIBNAME statement with the XLSX engine create Excel workbooks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

Which of the following is not a valid ODS statement?

a. ods csvall file=’c:\temp\myfile.csv’;
b. ods pdf file=’c:\temp\myfile.pdf’;
c. ods powerpoint file=’c:\temp\myfile.ppt’;
d. ods word file=’c:\temp\myfile.doc’;

A

d. ods word file=’c:\temp\myfile.doc’; - correct

Explain: WORD is not a valid destination for the ODS statement. The RTF destination creates a file that can be opened by word processors: ods rtf file=’c:\temp\myfile.rtf’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

Which statement needs to be added to the end of this program?
ods pdf file=’c:\temp\myfile.pdf’;

proc print data=sashelp.class;
run;

a. ods clear;
b. ods close;
c. ods pdf clear;
d. ods pdf close;

A

d. ods pdf close; - correct

Explain: The CLOSE argument closes the destination and the file that is associated with it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

Which statement is false concerning the options for the ODS statement?

a. The STYLE= option names the desired font.
b. The FILE= option specifies the output file to create.
c. The STARTPAGE= option controls the behavior of page breaks.
d. The PDFTOC= option controls the level of the expansion of the table of contents in PDF documents.

A

a. The STYLE= option names the desired font. - correct

Explain: The STYLE= option names the style to use in the output file. The style controls visual aspects such as colors and fonts.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

Which statement contains valid syntax for specifying a worksheet name?

a. ods excel sheet_name=’Males’;
b. ods excel (sheet_name=’Males’);
c. ods excel option(sheet_name=’Males’);
d. ods excel options(sheet_name=’Males’);

A

d. ods excel options(sheet_name=’Males’);

Explain: SHEET_NAME= is a sub-option that goes in a set of parentheses for the OPTIONS option.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q
What is the correct order of the following four clauses?
 a.  from ...
     select ...
      where ...
       order by ...

b. order by …
from …
select …
where …

c. select …
where …
order by …
from …

d. select …
from …
where …
order by …

A
d.  select ...
     from ...
      where ...
       order by ...
- correct

Explain: First is SELECT, second is FROM, third is WHERE, and fourth is ORDER BY.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

Which of the following is false regarding the SQL procedure?

a. Column names are separated with commas.
b. The procedure ends with a QUIT statement.
c. Formats can be specified in the FROM clause.
d. The SELECT and FROM clauses are required in the SELECT statement.

A

c. Formats can be specified in the FROM clause.
- correct

Explain: Formats are specified in the SELECT clause after the column name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

Which syntax is valid for creating a computed column in the SELECT clause?

a. Ratio = Height/Weight
b. Ratio as Height/Weight
c. Height/Weight = Ratio
d. Height/Weight as Ratio

A

d. Height/Weight as Ratio - correct

Explain: Computed columns are created by specifying the expression, the keyword AS, and the column name, in that order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

The SELECT statement creates a report. Which clause can be added before the SELECT clause to create a table?

a. create work.new =
b. create work.new table
c. create table work.new as
d. create table=work.new as

A

c. create table work.new as - correct

Explain: To create a table, add the CREATE TABLE NEW-TABLE-NAME AS clause before the SELECT clause.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q

Which SELECT statement produces the given output?
Name Height
Thomas 57.5
Joyce 51.3

a.  select Name Height
      from sashelp.class
      where age=12
      order by Height;
 b.  select Name, Height
      from sashelp.class
      where age=12
      order by Height desc;
 c.  select Name Height
      from sashelp.class
      where age=12
      order by desc Height;
 d.  select Name, Height
      from sashelp.class
      where age=12
      order by desc Height;
A
b.  select Name, Height
      from sashelp.class
      where age=12
      order by Height desc;  - correct

Explain: In the SELECT clause, column names are separated with commas. In the ORDER BY clause, DESC goes after the column name. ASC is the default sort order.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

Which SQL statement can delete tables?

a. DROP
b. VOID
c. DELETE
d. SELECT

A

a. DROP - correct

Explain: The DROP TABLE statement deletes tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
66
Q

If an inner join is performed on the following tables based on the ID and IDNO columns, how many rows will be in the PROC SQL report?

Name ID
Jack 111
Mary 333
Jane 555

IDNO Salary
111 75000
222 83000
333 82000

a. one
b. two
c. three
d. four

A

b. two - correct

Explain: An inner join gives matches only. Jack (111) and Mary (222) are the matches in this example.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
67
Q

Which statement has the correct syntax for performing an inner join?
a. select ID, Name, Salary
from one join two
on ID=IDNO;

b. select ID, Name, Salary
from one join two
where ID=IDNO;

c. select ID, Name, Salary
from one inner join two
on ID=IDNO;

d. select ID, Name, Salary
from one inner join two
where ID=IDNO;

A

c. select ID, Name, Salary
from one inner join two
on ID=IDNO; - correct

Explain: To perform an inner join, specify INNER JOIN between two table names and specify the matching condition in an ON clause (not a WHERE clause).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
68
Q

Which ON clause has valid qualifying syntax?
a. from empsau inner join phonec
on e.empid=p.empid;

b. from empsau inner join phonec
on left.empid=right.empid;

c. from empsau inner join phonec
on first.empid=second.empid;

d. from empsau inner join phonec
on empsau.empid=phonec.empid;

A

d. from empsau inner join phonec
on empsau.empid=phonec.empid; - correct

Explain: To qualify a column, put the table name and a period before the column name. Qualifying is needed when a column is in multiple tables. The name empsau.empid refers to the empid column in the empsau table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
69
Q

Which FROM clause properly creates aliases?

a. from empsau=e inner join phonec=p
b. from empsau(e) inner join phonec(p)
c. from empsau as e inner join phonec as p
d. from empsau of e inner join phonec of p

A

c. from empsau as e inner join phonec as p - correct

Explain: To create an alias in the FROM clause, put the word AS and the alias after the table name. The word AS is optional. The alias can be used when qualifying a column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
70
Q

Which statement is false concerning the compilation phase of the DATA step?

a. Initial values are assigned to the columns.
b. The program data vector (PDV) is created.
c. The DATA step is checked for syntax errors.
d. The descriptor portion of the output table is created.

A

a. Initial values are assigned to the columns. - correct

Explain: Initial values are assigned to columns at the beginning of the execution phase.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
71
Q

Which statement is not a compile-time-only statement?

a. KEEP
b. LENGTH
c. SET
d. WHERE

A

c. SET - correct

Explain: At execution time, the SET statement is processed to read data into the PDV. The compile-time statements of KEEP, LENGTH, and WHERE are not processed at execution time. The rules of these statements are processed in the compilation phase so that their impact will be observed in the output table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
72
Q

Which statement is true concerning the execution phase of the DATA step?

a. Data is processed in the program data vector (PDV).
b. An implied OUTPUT occurs at the top of the DATA step.
c. An implied REINITIALIZE occurs at the bottom of the DATA step.
d. Columns read from the input table are set to missing when SAS returns to the top of the DATA step.

A

a. Data is processed in the program data vector (PDV). - correct

Explain: During execution, data manipulation occurs in the PDV. An implied OUTPUT and RETURN (not REINITIALIZE) occurs at the bottom of the DATA step. When SAS returns to the top of the DATA step, columns read from the input table are retained and computed columns are set to missing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
73
Q

The DATA step debugger in SAS Enterprise Guide can be used with DATA and PROC steps.

a. True
b. False

A

b. False - correct

Explain: The DATA step debugger in SAS Enterprise Guide works only with DATA steps.

74
Q

Which PUTLOG statements create the following results in the SAS log?

Name=Alfred Height=69 Weight=112.5 Ratio=0.61 ERROR=0 N=1
Ratio=0.61

a. putlog all; putlog Ratio;
b. putlog all; putlog Ratio=;
c. putlog all; putlog Ratio;
d. putlog all; putlog Ratio=;

A

d. putlog all; putlog Ratio=; - correct

Explain: ALL is a keyword to show all of the contents of the PDV. Ratio= writes out the column name, an equal sign, and the value of Ratio. Ratio writes out only the value.

75
Q

How many rows and columns are in the output table ShippingZones given the following information?

The input table Shipping contains 5 rows and 3 columns (Product, BoxSize, and Rate).

data ShippingZones;
    set Shipping;
    Zone=1;
    output;
    Zone=2;
    Rate=(Rate*1.5);
run;
A

b. 5 rows and 4 columns - correct

Explain: The explicit OUTPUT statement is sending the ZONE=1 rows to the output table. There is no explicit OUTPUT statement after ZONE=2, so those rows are not making it to the output table. An implicit OUTPUT is not at the bottom of the DATA step due to the explicit OUTPUT. The four columns are Product, BoxSize, Rate, and Zone.

76
Q

The sashelp.cars table contains 428 rows: 123 rows with Origin equal to Europe and 305 rows with Origin equal to other values.

data Europe Other;
    set sashelp.cars;
    if Origin='Europe' then 
       output Europe;
    output Other;
run;

How many rows will be in the Other table?

A

d. 428 rows - correct

Explain: The OUTPUT statement outputs every row to the Other table.

77
Q

Which statement is false?

a. The KEEP statement names the columns to include from the input table.
b. The DROP statement names the columns to exclude from the output table.
c. The KEEP= option in the DATA statement names the columns to include in the output table.
d. The DROP= option in the SET statement names the columns to exclude from being read into the PDV.

A

a. The KEEP statement names the columns to include from the input table. - correct

Explain: The KEEP statement controls which columns are in the output table.

78
Q

Which columns are in the final table work.boots?

data work.boots(drop=Product); 
    set sashelp.shoes(keep=Product Subsidiary Sales Inventory);
    where Product='Boot';
    drop Sales Inventory;
    Total=sum(Sales,Inventory);
run;

a. Subsidiary
b. Subsidiary and Total
c. Product and Subsidiary
d. Product, Subsidiary, Sales, and Inventory

A

b. Subsidiary and Total - correct

Explain: The column Subsidiary from the input table and the calculated column Total are in the final table. Product, Sales, and Inventory are dropped.

79
Q

What is the result of running the following DATA step?

data work.boots;
set sashelp.shoes(keep=Product Subsidiary);
where Product=’Boot’;
NewSales=Sales*1.25;
run;
a. The step produces work.boots with three columns.
b. The step produces work.boots with four columns.
c. The step produces an error due to invalid syntax for the KEEP= option.
d. The step produces an error because the Sales column is not read in from the sashelp.shoes table.

A

b. The step produces work.boots with four columns. - correct

Explain: The table work.boots is created with the columns of Product, Subsidiary, NewSales, and Sales. The values of NewSales and Sales are missing. Sales is uninitialized because the value was not read in from the input table.

80
Q

Which statement contains valid syntax for the RETAIN statement?

a. retain Year 2018;
b. retain Year*2018;
c. retain Year=2018;
d. retain Year{2018};

A

a. retain Year 2018; - correct

Explain: You retain the column Year with an initial value of 2018. A space goes between the retain column and the initial value.

81
Q

Which statement is false concerning the sum statement?

a. The sum statement ignores missing values.
b. The sum statement initially sets the accumulator column to missing.
c. The sum statements adds a numeric value to an accumulator column.
d. The sum statement automatically retains the value of the accumulating column.

A

b. The sum statement initially sets the accumulator - correct

Explain: The sum statement ignores missing values, initially sets the accumulator column to 0, adds a numeric value to an accumulator column, and automatically retains the value of the accumulator column.

82
Q

What is the value of Count at the end of the third DATA step iteration?

data newnums;
    set nums;
    retain Count 100;
    Count+Tens;
run;
work.nums
Tens
10
20
30
40
A

d. 160 - correct

Explain: The initial value of Count is 100. The end of the first iteration is 100+10=110. The end of the second iteration is 110+20=130. The end of the third iteration is 130+30=160.

83
Q

What is the value of Count at the end of the third DATA step iteration?

data newnums;
set nums;
Count+Tens;
run;

work.nums
Tens
10
20
.
40
A

c. 30 - Correct

Explain: The initial value of Count is 0. The end of the first iteration is 0+10=10. The end of the second iteration is 10+20=30. The end of the third iteration is 30+.=30. The sum statement ignores missing values.

84
Q

Which step executes successfully without an error, given the input table sashelp.class?

Name Sex Age Height Weight
Alfred M 14 69 112.5
Alice F 13 56.5 84

a.  data new;
         set sashelp.class;
         Ratio=Height/Weight;
         where Sex='M' & Ratio>0.6;
     run;
 b.  data new;
         set sashelp.class;
         where Sex='M'; 
         Ratio=Height/Weight;
         where Ratio>0.6;
     run;
 c.  data new;
         set sashelp.class;
         where Sex='M'; 
         Ratio=Height/Weight;
         if Ratio>0.6;
     run;
 d.  data new;
         set sashelp.class;
         if Sex='M'; 
         Ratio=Height/Weight;
         where Ratio>0.6;
     run;
A
c.  data new;
         set sashelp.class;
         where Sex='M'; 
         Ratio=Height/Weight;
         if Ratio>0.6;
     run; - correct

Explain: The WHERE statement subsets data as it is being read into the PDV. Ratio is not in the input table, so Ratio cannot be specified in the WHERE statement. To subset Ratio, the condition must be specified in an IF statement.

85
Q

Which statement is true given the following program?

data work.student;
set sashelp.class;
by Name;
run;
a. The PDV contains a temporary variable named First.Name.
b. The output table work.student contains a column named Last.Name.
c. The DATA step sorts the input table by the column Name.
d. An error is produced because the BY statement is not permitted in the DATA step.

A

a. The PDV contains a temporary variable named First.Name. - correct

Explain: The BY statement produces the columns First.Name and Last.Name in the PDV, assuming the input table is sorted by Name. These columns will not be in the output table.

86
Q

What are the correct values for First.Name and Last.Name if the value of Name appears only once in the input table?

data work.student;
    set sashelp.class;
    by Name;
run;  
 a.  First.Name=0 and Last.Name=0
 b.  First.Name=1 and Last.Name=1
 c.  First.Name=1 and Last.Name=0
 d.  First.Name=0 and Last.Name=1
A

b. First.Name=1 and Last.Name=1 - correct

Explain: If First.Name and Last.Name are both equal to 1, the Name value is unique to that row. It is the first time and the last time that the Name value appears.

87
Q

Which DATA step statement indicates to continue processing the last row of a BY group?

a. if First.JobTitle;
b. if Last.JobTitle;
c. where First.JobTitle=1;
d. where Last.JobTitle=1;

A

b. if Last.JobTitle; - correct

Explain: This statement is true if Last.JobTitle is equal to a nonzero or nonmissing value. Therefore, this statement is true when Last.JobTitle is equal to 1.

88
Q

Which statement needs to be added to the DATA step to reset the value of Total for each new BY group?

data RegionTotal;
    set Sales;
    by Region;
    ... add statement here ...
    Total+Sales;
    if Last.Region=1 then output;
run;
 a.  Total=0;
 b.  if Last.Region=0 then Total=0;
 c.  if First.Region=0 then Total=0;
 d.  if First.Region=1 then Total=0;
A

d. if First.Region=1 then Total=0; - correct

Explain: First.Region=1 represents the beginning of each new BY group. When First.Region is equal to 1, the value of the accumulator column needs to be set to 0.

89
Q

What are the values for First.City and Last.City for the third row of the input table given the following information?

data StatePopulation;
set Population;
by State City;
run;

State	City	     Population
NC          Cary        162320
NC        Durham     263016
NC       Greenville   91495
SC       Greenville    67453
SC         Sumter       40723

a. First.City=0 and Last.City=0
b. First.City=1 and Last.City=0
c. First.City=0 and Last.City=1
d. First.City=1 and Last.City=1

A

d. First.City=1 and Last.City=1 - correct

Explain: The values of First.City and Last.City are dependent on the values of State. For the third row, First.City is equal to 1 because that is the first time that Greenville appears within NC. Last.City is equal to 1 because that is the last time Greenville appears within NC.

90
Q

Functions and CALL routines both return a value that must be used in an assignment statement or expression.

a. True
b. False

A

b. False - correct

Explain: A function returns a value that must be used in an assignment statement or expression, but a CALL routine alters existing column values or performs other system functions.

91
Q

Which function calculates the average of the columns Week1, Week2, Week3, and Week4?

a. mean(Week1, Week4)
b. mean(Week1-Week4)
c. mean(of Week1, Week4)
d. mean(of Week1-Week4)

A

d. mean(of Week1-Week4) - correct

Explain: Numeric column lists are specified with a hyphen between the first and last columns in the range. The keyword OF must be used if a column list is used as an argument in a function.

92
Q

Which expression rounds each value of Sales to the nearest hundredth (or two decimal places)?

a. round(Sales)
b. round(Sales, 2)
c. round(Sales, .01)
d. round(Sales, dollar10.2)

A

c. round(Sales, .01) - correct

Explain: Use the second argument in the ROUND function to specify the rounding unit.

93
Q

Which function could be used to remove the non-numeric symbols in Phone?

Phone
202-555-0190
202.555.0110
(202)555-0133
[202]555-0128

a. COMPRESS
b. COMPBL
c. SCAN
d. FIND

A

a. COMPRESS - correct

Explain: The second argument of the COMPRESS function can be used to specify all symbols to remove from the values of Phone, as shown in the following example: Phone=compress(Phone, ‘-.()[] ‘);

The optional third argument of COMPRESS could further simplify this code by working with entire character classes instead of having to specify individual characters. For example, the ‘d’ modifier specifies only digits, and the ‘k’ modifier instructs COMPRESS to keep the specified items instead of removing them. So specifying ‘kd’ for the third argument causes COMPRESS to keep only digits. The following example illustrates this use of the third argument of COMPRESS: Phone=compress(Phone,,’kd’);

94
Q

Which statement reads CityCountry and correctly assigns a value to Country?

City Country Country
Athens, Greece Greece
New Delhi, India India
Auckland, New Zealand New Zealand

a. Country=scan(CityCountry, 2);
b. Country=scan(CityCountry, -1);
c. Country=scan(CityCountry, 2, ‘,’);
d. Country=scan(CityCountry, 2, ‘, ‘);

A

c. Country=scan(CityCountry, 2, ‘,’); - correct

Explain: The SCAN function should return the second word using only the comma as a delimiter.

95
Q

Which expression creates CityCountry?

City Country CityCountry
Athens Greece Athens, Greece
New Delhi India New Delhi, India
Auckland New Zealand Auckland, New Zealand

a. cat(City, “, “, Country)
b. cats(“, “, City, Country)
c. catx(City, “, “, Country)
d. catx(“, “, City, Country)

A

d. catx(“, “, City, Country) - correct

Explain: The CATX function concatenates strings together, removes leading and training blanks, and inserts the separator that is defined as the first argument.

96
Q

How many rows are written to output based on the following statement?

if find(Location, “Oahu”, “i”) > 0 then output;

Location
Honolulu, Oahu
Kaanapali, Maui
Hilo, Hawaii
kailua, oahu
LAIE, OAHU

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

A

c. 3 - correct

Explain: The “I” modifier as the third argument in the FIND function makes the search case insensitive.

97
Q

Which of the following functions can convert the values of the numeric variable Level to character values?

a. put(Level, 3.)
b. put(3., Level)
c. input(3., Level)
d. input(Level, 3.)

A

a. put(Level, 3.) - correct

Explain: 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.

98
Q

Which of the following functions converts the character values of Base to numeric values?

a. put(comma10.2, Base)
b. put(Base, comma10.2)
c. input(Base, comma10.2)
d. input(comma10.2, Base)

A

c. input(Base, comma10.2) - correct

Explain: 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.

99
Q

Which step is not required when converting a character column named Date to a numeric SAS date column with the same name?

a. Rename the Date column to a new name, such as CharDate.
b. Use the INPUT function to read the renamed CharDate character column and create a numeric column named Date.
c. Specify an appropriate informat in the INPUT function.
d. Format the new numeric Date column.

A

d. Format the new numeric Date column. - correct

Explain: Formatting the new column is not required but is recommended.

100
Q
Which of the following contains valid syntax?
 a.  value grades 'A'='Excellent'
	          'B'='Good';
 b.  value qtrfmt 1,2,3='First'
		  4,5,6='Second';
 c.  value $grades. 'A'='Excellent'
	            'B'='Good';
 d.  value qtrfmt '1'-'3'='First' 
	          '4'-'6'='Second';
A

b. value qtrfmt 1,2,3=’First’
4,5,6=’Second’; - correct
Explain: This VALUE statement creates a numeric format, and numeric values are specified. In answer choice a, the VALUE statement is creating a numeric forma,t but character values are specified. In answer choice c, the VALUE statement contains a period in the format name. In answer choice d, the VALUE statement is creating a numeric format, but character values are specified.

101
Q

What is the formatted value for the value of 100 given the following step?

proc format;
value rates 1-<100=’low’
100

A

d. out of range - correct

Explain: 100 falls into the OTHER category. 1-<100 is less than 100. 100

102
Q

In the FORMAT procedure, you specify the name of the format and the name of the column that will use the custom format.

a. True
b. False

A

b. False - correct

Explain: The format name is specified in the VALUE statement of PROC FORMAT. However, PROC FORMAT has no reference to the table or column to be formatted. Those items appear in other steps, such as a FORMAT statement within PROC PRINT.

103
Q

What is the correct formatted output given the following PROC FORMAT step and the input table?

proc format;
    value $answer '1'='Yes'
                  '2'='No'
                  'other'='Not Answered';
run;

Code
1
2
3

A
Code
Yes
No
3
- correct

Explain: The word other is in quotation marks. Therefore, it is not seen as a keyword. A value of 3 is not referenced by any of the values in the VALUE statement. The value 3 is displayed as 3.

104
Q

Which of the following does not have proper syntax for specifying a range in the VALUE statement?

a. 500>-700
b. 500-<700
c. ‘A’-‘C’
d. ‘Horse’-‘Mouse’

A

a. 500>-700 - correct

Explain: The greater than symbol is not valid for a range. The less than symbol can be used after the starting value or before the ending value.

105
Q

Which statement is true concerning options for the FORMAT procedure?

a. The FMTLIB option goes in the SELECT statement.
b. The CNTLIN= option goes in the VALUE statement.
c. The FMTLIB option specifies the library to store the format.
d. The CNTLIN= option specifies a table from which formats are built.

A

d. The CNTLIN= option specifies a table from which formats are built. - correct

Explain: CNTLIN= specifies the table to read in order to create a format. This option goes in the PROC FORMAT statement. The FMTLIB option goes in the PROC FORMAT statement and creates a report containing information about your custom formats.

106
Q

Which columns are required in an input table to create a format based on numeric ranges?

a. FMTNAME, START, and LABEL
b. FORMAT, START, END, and NAME
c. FMTNAME, START, END, and LABEL
d. FORMAT, START, LAST, NAME, and TYPE

A

c. FMTNAME, START, END, and LABEL - correct

Explain: At a minimum, FMTNAME, LABEL, and START are required for a CNTLIN= table. END is also needed for ranges.

107
Q

Which option in the PROC FORMAT statement specifies a library to store a custom format?

a. CATALOG=
b. FMTLIB=
c. LIBRARY=
d. STORE=

A

c. LIBRARY= - correct

Explain: The LIBRARY= option specifies the library or catalog (or both) that contains the formats that you are creating. The FMTLIB= option creates a report containing information about your custom formats. There is not a CATALOG= or STORE= option in the PROC FORMAT statement.

108
Q

What is the default search order that is used to locate formats?

a. LIBRARY.FORMATS > WORK.FORMATS
b. SASHELP.FORMATS > LIBRARY.FORMATS
c. SASHELP.FORMATS > WORK.FORMATS
d. WORK.FORMATS > LIBRARY.FORMATS

A

d. WORK.FORMATS > LIBRARY.FORMATS - correct

Explain: By default, SAS first looks in WORK.FORMATS. If the format is not in that location, SAS looks in LIBRARY.FORMATS.

109
Q

Which of the following contains valid syntax for the FMTSEARCH= option?

a. options fmtsearch=sashelp;
b. options fmtsearch=sashelp.formats;
c. options fmtsearch=(sashelp sashelp.fmts);
d. options fmtsearch=[sashelp.fmts sashelp];

A

c. options fmtsearch=(sashelp sashelp.fmts); - correct

Explain: The FMTSEARCH= option must specify search criteria in parentheses. After looking in the default locations, SAS looks in SASHELP.FORMATS and then SASHELP.FMTS.

110
Q

Which statement is true concerning concatenating tables?

a. All tables must have the same number of columns.
b. Columns in all tables must have matching names and lengths.
c. Tables must be in the same library.
d. Missing values are generated for columns that exist in one input table and not in another.

A

d. Missing values are generated for columns that exist in one input table and not in another. - correct

Explain: Tables with different columns can be concatenated, but missing values are generated for columns that exist in one input table and not in another.

111
Q

Which statement renames the existing column Location in work.travel as Destination?

a. set vacations(rename=(Location=Destination)) travel;
b. set vacations travel(rename=(Destination=Location));
c. set vacations travel(rename=(Location=Destination));
d. set vacations travel(rename(Destination=Location));

A

c. set vacations travel(rename=(Location=Destination)); - correct

Explain: Parentheses surround all data set options, and another set of parentheses surrounds the columns listed for the RENAME= data set option.

112
Q

Which statement is true concerning merging with matching rows?

a. The MERGE statement must refer to temporary input tables.
b. The columns in the BY statement can be in only one of the tables.
c. Only two input tables can be specified in the MERGE statement.
d. The input tables must be sorted by the columns in the BY statement.

A

d. The input tables must be sorted by the columns in the BY statement. - correct

Explain: With match-merging, each input table must first be sorted on the values of the BY columns or have an appropriate index.

113
Q

How many rows are in the both output table given the following input tables and code?

Name Age
Bob 12
Sue 15

Name	Food
Bob	        Pizza
Bob	     Cupcakes
Sue	      Burgers
Sue	      Grapes
Sue	     Brownies
data both;
    merge agetable 
          foodtable;
    by Name;
run;

a. two
b. three
c. four
d. five

A

d. five - correct

Explain: There will be two rows for Bob and three rows for Sue.

114
Q

How many rows are in the empsauc output table given the following input tables and code?

work.empsau
First	    Region	EmpID
Togar	E	       121150
Kylie	S	       121151
Birin	W	      121152
work.phonec
EmpID	Phone
121150	+61(2)5555-1795
121152	+61(2)5555-1667
121153	+61(2)5555-1348

data empsauc;
merge empsau phonec;
by EmpID;
run;

a. two
b. three
c. four
d. five

A

c. four - correct

Explain: There will be a matching row for 121150, a nonmatching row for 121151, a matching row for 121152, and a nonmatching row for 121153.

115
Q

What is the result of the following step?

data combine;
merge donors1 donors2;
by ID;
run;

work.donors1
ID	    Type	Units
2304	O	16
1129	        A	48
1129	        A	50
2486	B	63
work.donors2
ID	     Code	 Units
1129	        63	   32
2304	61	   45
1387	64	   67

a. The table combine is created with four columns and five rows.
b. The step fails because the BY column ID is not properly sorted.
c. The step fails because Units is in both tables and not the BY column.
d. The step fails because of duplicate ID values within the donors1 table.

A

b. The step fails because the BY column ID is not properly sorted. - correct

Explain: The two tables are not sorted by ID, so the step produces an error.

116
Q

Which statement best describes the rows in the output table?

data bonuses;
    merge managers(in=M)
          staff(in=S);
    by EmpID;
    if M=0 and S=1;
run;

a. all the matching rows from both managers and staff
b. only the rows from managers that have no match in staff
c. only the rows from staff that have no match in managers
d. all the matching and nonmatching rows from both managers and staff

A

c. only the rows from staff that have no match in managers - correct

Explain: S=1 specifies that the staff table must contribute to the row, and M=0 specifies that the managers table must not contribute to the row.

117
Q

What are the values of C and A during the third iteration of the DATA step?

work.clients
Name	          ID
Ankerton	11123
Davis	       22298
Masters	        33351
work.amounts
Name	      Amt
Ankerton	92
Ankerton	43
Masters	        27
data client_amount;
    merge clients(in=C) 
          amounts(in=A);
    by Name;
run;

a. C=0 and A=0
b. C=1 and A=0
c. C=0 and A=1
d. C=1 and A=1

A

b. C=1 and A=0 - correct

Explain: The third iteration is for the nonmatch of Davis. Davis is in the clients table (C=1) and not the amounts table (A=0).

118
Q

What is the value of Location in the output table?

loc1
Code Location
A France

loc2
Code Location
A Belgium

loc3
Code Location
A Italy

data locALL;
    merge loc1 loc2 loc3;
    by Code;
run;
a.  Italy
b.  France
c.  Belgium
d.  France Belgium Italy
A

a. Italy - correct

Explain: The value of Location is based on the last table read. The loc3 table has a value of Italy for Location.

119
Q

A single DATA step can be used to merge the following three tables:

dataset1
Student Test Score

dataset2
Subject Test

dataset3
Subject AvgScore

a. True
b. False

A

b. False - correct

Explain: Two DATA steps are needed. In the first DATA step, dataset1 and dataset2 can be merged by Test. In the second DATA step, dataset3 can be merged with the result of the first DATA step by Subject.

120
Q

Which output table does the following step produce?

data Earnings(keep=Qtr Earned);
    Amount=1000; Rate=.075/4;
    do Qtr=1 to 4;
       Earned+(Amount+Earned)*Rate;
    end;
run;
A

Qtr Earned
5 77.135865784 - correct

Explain: The implied OUTPUT occurs after the DO loop. The value of QTR is 5, which is one increment beyond the stop value of 4.

121
Q

Which statement is true regarding the iterative DO loop?

DO index-column = start TO stop ;

a. The start and stop values can be character or numeric values.
b. If an increment value is not specified, the default increment is 0.
c. The index column is incremented at the bottom of each DO loop.
d. The index column is not in the final table unless specifically kept.

A

c. The index column is incremented at the bottom of each DO loop. - correct

Explain: The index column is incremented at the bottom of each DO loop. The start and stop values must be numeric when used with the keyword TO. The default increment is 1. The index column is in the final table unless specifically dropped.

122
Q

How many rows are in the savings output table given the following input table and code? Note: Amount is a numeric column.

pg2.savings
Name	Amount
James	250
Linda	300
Mary	275
Robert	350
data work.savings;
    set pg2.savings;
    Savings=0;
    do Year=1 to 5;
       do qtr=1 to 4;
          Savings+Amount;
          Savings+(Savings*0.02/12);
       end;
    end;
run;

a. 1
b. 4
c. 5
d. 20

A

b. 4 - correct

Explain: Four rows are in the output table, one row per each row in the input table. The implied OUTPUT is after the nested DO loops.

123
Q

What is the final value of Year given the following step?

data invest;
    do Year=2010 to 2019;
       Capital+5000;
       Capital+(Capital*.03);
    end;
run;
 a.  . (missing)
 b.  2010
 c.  2019
 d.  2020
A

d. 2020 - correct

Explain: The final value of Year is 2020, which is one increment beyond the stop value of 2019.

124
Q

Which of the following statements contains valid syntax?

a. do 1 to 10 by 2;
b. do while (Year>2025);
c. do until Earnings<=100000;
d. do date=’01JAN2019’ to ‘31JAN2019’;

A

b. do while (Year>2025); - correct

Explain: When WHILE or UNTIL is used in the DO statement, the expression must be in a set of parentheses. In answer choice a, the index column is missing. In answer choice c, the parentheses are missing around the expression. In answer choice d, the DATE values are character instead of numeric (‘01JAN2019’d).

125
Q

How many rows are in the bikeinfo2 output table given the following input table and code?

work.bikeinfo
name bike
Marco 12
Angela 10

data bikeinfo2;
    set bikeinfo;
    do month=1 to 3;
       do week=1 to 4;
          bike=bike+2;
       end;
    output;
    end;
run;

a. 2
b. 3
c. 6
d. 12
e. 24

A

c. 6 - correct

Explain: For each row read in, 3 rows are created (1 for each of 3 months). So, 2 rows read * 3 months = 6 rows.

126
Q

What is the value of x at the completion of the DATA step?

data test;
    x=15;
    do until(x>12);
       x+1;
    end;
run;
 a.  . (missing)
 b.  13
 c.  15
 d.  16
A

d. 16 - correct

Explain: A DO UNTIL is evaluated at the bottom. The initial value of x is 15. The DO loop occurs one time, even though 15 is greater than 12, because the condition is not checked until the bottom of the loop. Therefore, 15 becomes 16 before the condition is checked.

127
Q

Which statement is false?

a. The DO UNTIL loop executes until a condition is true.
b. The DO WHILE loop always executes at least one time.
c. The DO WHILE loop checks the condition at the top of the loop.
d. The DO UNTIL loop checks the condition at the bottom of the loop.

A

b. The DO WHILE loop always executes at least one time. - correct

Explain: The DO UNTIL loop always executes at least one time because the condition is checked at the bottom of the loop. The DO WHILE loop executes only if the condition is true, because the condition is checked at the top of the loop.

128
Q

Which of the following statements contains valid syntax?

a. do Age=10 to 14 and while (Weight<150);
b. do week=1 to 52 do until (Mileage ge 2750);
c. do Increase=5 to 10 while (temperature lt 102);
d. do Year=2018 to 2028 or until (Earnings<=100000);

A

c. do Increase=5 to 10 while (temperature lt 102); - correct

Explain: When combining an iterative with a conditional, you cannot use extra words such as AND, DO, or OR. The conditional immediately follows the iterative.

129
Q

Which output table does the following step produce?

data test;
    bike=10;
    do day=1 to 7 while (bike lt 13);
       bike=bike+2;
    end;
run;
a.  
Bike	Day
14	2
 b.  
Bike	Day
14	3
 c.  
Bike	Day
24	7
 d.  
Bike	Day
24	8
A

b.
Bike Day
14 3
- correct

Explain: On the second iteration of the DO loop, Day=2 and Bike=14. At the bottom of the loop, Day becomes 3. At the top of the loop, the condition is checked. The value 14 exceeds 13, so the DO loop is over with Day=3 and Bike=14.

130
Q

Which is the better description for the following table?

Year Jan Feb Mar Apr May Jun
Yr1956 284 277 317 313 318 374
Yr1957 315 301 356 348 355 422
Yr1958 340 318 362 348 363 435

a. wide table
b. narrow table

A

a. wide table - correct

Explain: The measures are split into multiple columns, so this is called a wide table.

131
Q

When using the DATA step to go from a wide tabe to a narrow table, which statement is needed for creating multiple rows from a single row?

a. WIDE
b. NARROW
c. RETAIN
d. OUTPUT

A

d. OUTPUT - correct

Explain: When going from a wide table to a narrow table, the OUTPUT statement is needed to create multiple rows from a single row during one iteration of the DATA step.

132
Q

How many rows will be in the final table if work.airwide contains three rows?

data work.airnarrow;
    set work.airwide;
    Month='Jan';
    Air=Jan;
    output;
    Month='Feb';
    Air=Feb;
    output;
    Month='Mar';
    Air=Mar;
    output;
    keep Year Month Air;
run;
 a.  3
 b.  6
 c.  9
 d.  12
A

c. 9 - correct

Explain: For each row read from the input table work.airwide, 3 rows are created (1 for January data, 1 for February data, and 1 for March data). Because there are 3 rows in the input table, the final table work.airnarrow will contain 9 rows (3 input rows * 3 rows created per each iteration).

133
Q

When using the DATA step to go from a narrow table to a wide table, the KEEP statement is needed to hold values in the PDV across multiple iterations of the DATA step.

a. True
b. False

A

b. False

Explain: The RETAIN statement is needed when using the DATA step to go from a narrow table to a wide table. The RETAIN statement holds values in the PDV across multiple iterations of the DATA step. The KEEP statement controls the columns that make it to the final table.

134
Q

Which statement needs to be added to the DATA step to include only the last row per value of Year in the output table?

data work.airwide2(keep=Year Jan Feb Mar);
    set work.airnarrow;
    by Year;
    retain Jan Feb Mar;
    if Month='Jan' then Jan=Air;
    else if Month='Feb' then Feb=Air;
    else if Month='Mar' then Mar=Air;
    ... insert statement here ...
run;
 a.  output;
 b.  if Last then output;
 c.  if Last.Year=1 then output;
 d.  if Last.Year=0 then output;
A

c. if Last.Year=1 then output; - correct

Explain: Due to the BY statement, the PDV contains a column named First.Year and a column named Last.Year. Last.Year will be equal to 1 when the last row of Year is read in from the input table. It is during this iteration that the PDV contents need to be output.

135
Q

Which statement is false concerning the TRANSPOSE procedure?

a. Columns are transposed into rows.
b. By default, numeric columns are transposed.
c. Use a BY statement to sort the data while transposing.
d. Use a VAR statement to specify the character and numeric columns to transpose.

A

c. Use a BY statement to sort the data while transposing. - correct

Explain: PROC TRANSPOSE cannot sort the data. The data needs to be sorted before the PROC TRANSPOSE statement. The BY statement transposes data within groups.

136
Q

Which statements are needed in a PROC TRANSPOSE step for the following example (narrow to wide)?

Narrow Table
Day	                Meal	Food
Saturday	     Breakfast	Yogurt
Saturday	      Lunch	Sandwich
Saturday	      Dinner	Steak
Sunday	     Breakfast	Pancakes
Sunday	        Lunch	Salad
Sunday	      Dinner	Lasagna

Wide Table
Day Breakfast Lunch Dinner
Saturday Yogurt Sandwich Steak
Sunday Pancakes Salad Lasagna

a.  by Day;
     var Meal Food;
 b.  id Day;
     var Food Meal;
 c.  by Day;
     id Food;
     var Meal;
 d.  by Day;
     id Meal;
     var Food;
A

d. by Day;
id Meal;
var Food; - correct

Explain: The BY statement transposes the data by the grouping of Day. The ID statement uses the values of Meal as the column headings. The VAR statement transposes the Food values into rows.

137
Q

Which statement or statements are needed in a PROC TRANSPOSE step for the following example (wide to narrow)?

Wide Table
Day Breakfast Lunch Dinner
Saturday Yogurt Sandwich Steak
Sunday Pancakes Salad Lasagna

Narrow Table
_NAME_	          COL1	     COL2
Breakfast	Yogurt	     Pancakes
Lunch	        Sandwich	Salad
Dinner	         Steak	     Lasagna

a. by Day;
b. var Breakfast Lunch Dinner;
c. id Day;
d. id Day;
var Breakfast Lunch Dinner;

A

b. var Breakfast Lunch Dinner; - correct

Explain: The columns of Breakfast, Lunch, and Dinner are transposed into rows.

138
Q

Which option is needed in the PROC TRANSPOSE statement to rename the NAME column as shown in the output table?

Input Table
_NAME_	        COL1	COL2
Breakfast	Yogurt	Pancakes
Lunch	      Sandwich	Salad
Dinner	        Steak	Lasagna
Output Table
Meal	        COL1	COL2
Breakfast	Yogurt	Pancakes
Lunch	        Sandwich	Salad
Dinner	          Steak	Lasagna

a. name=Meal
b. name=Meal
c. prefix=Meal
d. rename=Meal

A

b. name=Meal - correct

Explain: The NAME= option specifies the name for the column in the output table that contains the name of the column that is being transposed to create the current row. The default name is NAME.

139
Q

Which option is needed in the PROC TRANSPOSE statement to rename the COL columns as shown in the output table?

Input Table
Meal	        COL1	COL2
Breakfast	Yogurt	Pancakes
Lunch	        Sandwich	Salad
Dinner	          Steak	Lasagna
Output Table
Meal	         Day7	Day1
Breakfast	Yogurt	Pancakes
Lunch	        Sandwich	Salad
Dinner	          Steak	Lasagna

a. out=meals2(COL1=Day7 COL2=Day1)
b. out=meals2(name=(COL1=Day7 COL2=Day1))
c. out=meals2(rename=(COL1=Day7 COL2=Day1))
d. out=meals2(prefix=(COL1=Day7 COL2=Day1))

A

c. out=meals2(rename=(COL1=Day7 COL2=Day1)) - correct

Explain:
The RENAME= data set option can be used to change the names of the COL columns.

140
Q
  • ************;
  • LESSON 2, PRACTICE 1 *;
  • a) Complete the PROC IMPORT step to read *;
  • EU_SPORT_TRADE.XLSX. Create a SAS table named *;
  • EU_SPORT_TRADE and replace the table *;
  • if it exists. *;
  • b) Modify the PROC CONTENTS code to display the *;
  • descriptor portion of the EU_SPORT_TRADE table. *;
  • Submit the program, and then view the output data *;
  • and the results. *;
  • ************;
A

Coding Exercise.

141
Q

EPG1: LESSON 3, PRACTICE 4

A

Coding Exercise

142
Q

EPG1: LESSON 3, PRACTICE 8

A

Coding Exercise

143
Q

EPG1: LESSON 4, PRACTICE 1

A

Coding Exercise

144
Q

EPG1: LESSON 4, PRACTICE 4

A

Coding Exercise

145
Q

EPG1: LESSON 4, PRACTICE 7

A

Coding Exercise

146
Q

EPG1: LESSON 5, PRACTICE 3

A

Coding Exercise

147
Q

EPG1: LESSON 6, PRACTICE 1

A

Coding Exercise

148
Q

EPG1: LESSON 6, PRACTICE 2

A

Coding Exercise

149
Q

EPG1: LESSON 6, PRACTICE 3

A

Coding Exercise

150
Q

EPG2: LESSON 1, PRACTICE 1

A

Coding Exercise

151
Q

EPG2: LESSON 1, PRACTICE 2

A

Coding Exercise

152
Q

EPG2: LESSON 1, PRACTICE 3

A

Coding Exercise

153
Q

EPG2: LESSON 1, PRACTICE 5

A

Coding Exercise

154
Q

EPG2: LESSON 2, PRACTICE 1

A

Coding Exercise

155
Q

EPG2: LESSON 2, PRACTICE 4

A

Coding Exercise

156
Q

EPG2: LESSON 3, PRACTICE 1

A

Coding Exercise

157
Q

EPG2: LESSON 3, PRACTICE 2

A

Coding Exercise

158
Q

EPG2: LESSON 3, PRACTICE 3

A

Coding Exercise

159
Q

EPG2: LESSON 3, PRACTICE 4

A

Coding Exercise

160
Q

EPG2: LESSON 3, PRACTICE 5

A

Coding Exercise

161
Q

EPG2: LESSON 3, PRACTICE 6

A

Coding Exercise

162
Q

EPG2: LESSON 4, PRACTICE 1

A

Coding Exercise

163
Q

EPG2: LESSON 4, PRACTICE 2

A

Coding Exercise

164
Q

EPG2: LESSON 4, PRACTICE 3

A

Coding Exercise

165
Q

EPG2: LESSON 4, PRACTICE 4

A

Coding Exercise

166
Q

EPG2: LESSON 4, PRACTICE 5

A

Coding Exercise

167
Q

EPG2: LESSON 4, PRACTICE 6

A

Coding Exercise

168
Q

EPG2: LESSON 5, PRACTICE 1

A

Coding Exercise

169
Q

EPG2: LESSON 5, PRACTICE 3

A

Coding Exercise

170
Q

EPG2: LESSON 5, PRACTICE 5

A

Coding Exercise

171
Q

EPG2: LESSON 6, PRACTICE 1

A

Coding Exercise

172
Q

EPG2: LESSON 6, PRACTICE 2

A

Coding Exercise

173
Q

EPG2: LESSON 6, PRACTICE 3

A

Coding Exercise

174
Q

EPG2: LESSON 6, PRACTICE 4

A

Coding Exercise

175
Q

EPG2: LESSON 6, PRACTICE 5

A

Coding Exercise

176
Q

EPG2: LESSON 6, PRACTICE 6

A

Coding Exercise

177
Q

EPG2: LESSON 7, PRACTICE 1

A

Coding Exercise

178
Q

EPG2: LESSON 7, PRACTICE 1

A

Coding Exercise

179
Q

EPG2: LESSON 7, PRACTICE 1

A

Coding Exercise

180
Q

EPG2: LESSON 7, PRACTICE 1

A

Coding Exercise