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.