Base SAS Programming Quiz Flashcards
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. 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.
Running a SAS program can create which of the following?
a. log b. output data c. results d. all of the above
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.
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. 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.
Which of the following steps is typically used to generate reports and graphs?
a. DATA b. PROC c. REPORT d. RUN
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).
Does this comment contain syntax errors? /* Report created for budget presentation; revised October 15. */ proc print data=work.newloan; run;
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.
What result would you expect from submitting this step?
proc print data=work.newsalesemps
run;
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.
What happens if you submit the following program?
porc print data=work.newsalesemps;
run;
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.
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;
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 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;
c. seven - correct
Explain: This program contains seven statements (seven semicolons): comment, TITLE, FOOTNOTE, PROC, WHERE (two lines), VAR (two lines), and RUN.
Which of the following is not a SAS programming interface?
a. SAS Enterprise Guide b. SAS Manager c. SAS Studio d. SAS windowing environment
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.
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
b. 8 bytes - correct
Explain: Birth_Date is a numeric column, and all numeric columns in SAS are 8 bytes by default.
Which LIBNAME statement has the correct syntax?
a. libname reports “filepath/workshop”;
b. libname orion filepath/workshop;
c. libname 3456a “filepath/workshop”;
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.
Which of the following tables is available at the beginning of a new SAS session?
a. sales
b. work.newsalesemps
c. sashelp.class
c. sashelp.class - correct
Explain: The Sashelp library contains sample and resource tables provided by SAS. The library is automatically available when SAS starts.
What type of values are represented with a period when missing?
What type of values are represented with a space when missing?
Missing numeric values are represented with a period,
Missing character values are represented with a period,
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 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.
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”;
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.
Which library name (libref) is valid?
a. 2010Car
b. car/2010
c. car2010
d. cars_2010
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.
To disassociate a libref that you previously assigned, you can use the UNASSIGN option in the LIBNAME statement.
a. True
b. False
b. False - correct
Explain: Use the CLEAR option in the LIBNAME statement to disassociate an assigned libref.
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.
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.
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. descriptor portion - correct
Explain: The descriptor portion of a SAS table includes the table metadata.
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. 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
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.;
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.
The format name must include a period delimiter in the FORMAT statement.
a. True
b. False
a. True - correct
Explain: The period is a required syntax element in a format name within a FORMAT statement.
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
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.
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.
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.
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’);
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.
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
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.
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. %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.
Which statement in a PROC MEANS step lets you specify the numeric columns to analyze?
a. TABLES
b. VARS
c. VAR
d. KEEP=
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.
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?
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.
In which phase does the DATA step check for syntax errors?
a. compilation
b. execution
a. compilation - correct
Explain: Checking for syntax errors is the first step in the compilation phase.
Which statement is used to read a SAS data set in a DATA step?
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.
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
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.
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. work.us - correct
Explain: The output table is listed in the DATA statement.
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. four - correct
Explain: Only the four columns listed in the KEEP statement are written to the work.comp table.
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.
b. 8 - correct
Explain: The MEAN function ignores missing values, so the calculation is (10+5+9)/3=8.
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
b. MONTH(SAS-date-value) - correct
Explain: The MONTH function returns the month number (1-12) extracted from a SAS date value.
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
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.
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. 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.
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. True - correct
Explain: To execute more that one statement if a condition is true, you must use IF-THEN/DO groups.
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. 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.
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”;
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.
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.
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.
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.
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.
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. 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.
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;
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.
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.
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.
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
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.
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;
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.
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.
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.
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;
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.
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
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.
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;
b. libname sales clear; - correct
Explain: The CLEAR option in the LIBNAME statement disassociates one or more currently assigned librefs.
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. 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.
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
c. both - correct
Explain: Both ODS EXCEL and the LIBNAME statement with the XLSX engine create Excel workbooks.
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’;
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’;
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;
d. ods pdf close; - correct
Explain: The CLOSE argument closes the destination and the file that is associated with it.
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. 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.
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’);
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.
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 …
d. select ... from ... where ... order by ... - correct
Explain: First is SELECT, second is FROM, third is WHERE, and fourth is ORDER BY.
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.
c. Formats can be specified in the FROM clause.
- correct
Explain: Formats are specified in the SELECT clause after the column name.
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
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.
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
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.
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;
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.
Which SQL statement can delete tables?
a. DROP
b. VOID
c. DELETE
d. SELECT
a. DROP - correct
Explain: The DROP TABLE statement deletes tables.
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
b. two - correct
Explain: An inner join gives matches only. Jack (111) and Mary (222) are the matches in this example.
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;
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).
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;
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.
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
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.
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. Initial values are assigned to the columns. - correct
Explain: Initial values are assigned to columns at the beginning of the execution phase.
Which statement is not a compile-time-only statement?
a. KEEP
b. LENGTH
c. SET
d. WHERE
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.
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. 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.