1.3 & 1.4 Flashcards
Which SAS procedure allows you to view the descriptor portion of a table?
a) PROC FREQ
b) PROC MEANS
c) PROC UNIVARIATE
d) PROC CONTENTS
d) PROC CONTENTS
Which SAS procedure includes a report that shows the five lowest and highest extreme values and their observation numbers?
a) PROC FREQ
b) PROC MEANS
c) PROC UNIVARIATE
d) PROC CONTENTS
c) PROC UNIVARIATE
Which statistic is NOT included in the PROC MEANS procedure by default?
a) frequency count
b) mean
c) standard deviation
d) minimum
e) maximum
f) cumulative total
f) cumulative total
True/False - PROC MEANS procedure includes detailed statistics related to distribution.
False - PROC UNIVARIATE includes more detailed statistics related to distribution than PROC MEANS
Which of the following will create a report that lists the first 10 observations in the pg1.storm_summary table?
a) proc print data=storm_summary (obs=10);
run;
b) proc print data=pg1.storm_summary obs=10;
run;
c) proc print data=pg1.storm_summary (obs=10);
run;
d) proc print data=pg1.storm_summary
out=storm_top_ten (obs=10);
run;
c) proc print data=pg1.storm_summary (obs=10);
run;
True/False - The following procedure will run without error.
proc freq data=pg1.storm_summary;
var Basin Type Season;
run;
False - PROC freq uses the tables statement, not var.
proc freq data=pg1.storm_summary;
tables Basin Type Season;
run;
True/False - The PROC UNIVARIATE procedure can be used to identify case inconsistencies and incorrect values.
False - PROC FREQ can be used to identifies case inconsistencies and incorrect values.
Which statement is NOT true regarding the where statement?
a) It can be used with the PROC PRINT procedure
b) It can be used with the PROC MEANS procedure
c) It consists of the keyword WHERE and an assignment statement
d) It consists of the keyword WHERE and one or more expressions
Double check this answer. I think it should be C is not true.
d) It consists of the keyword WHERE and one or more expressions
An expression tests the value of a column against a condition that you specify.
Which of the following is NOT an operator that can be used in an expression?
a) = or EQ
b) ^= or ~= or NE
c) > or GT
d) < or LT
e) != or NE
f) <= or LE
e) != or NE
b) ^= or ~= or NE : these are the correct ways to specify not equal
True/False - When specifying expressions character values are case sensitive.
True
True/False - When specifying expressions numeric values can include special characters.
False - they must be standard numeric values. You cannot include special symbols such as commas or dollar signs.
Which of the following is correct syntax for combining multiple expressions in a WHERE statement?
a) where Type=’SUV’ & MSRP <= 30000;
b) where Type=’SUV’ || MSRP <= 30000;
c) where Type=”SUV” and MSRP <= 30000;
d) where Type=”SUV” and ~MSRP <=30000;
c) where Type=”SUV” and MSRP <= 30000;
You can combine multiple expressions with the keywords AND or OR in a WHERE statement.
True/False - The IN operator only works with character values.
False - The IN operator works with both numeric and character values. Character values are case sensitive and must be enclosed in quotation marks.
Which of the following is correct syntax for the expression?
a) where Type not in (“SUV”, “Truck”, “Wagon”);
b) where Type not (“SUV”, “Truck”, “Wagon”);
c) where Type NE (“SUV”, “Truck”, “Wagon”);
d) where Type not in (“SUV”, Truck, “Wagon”);
a) where Type not in (“SUV”, “Truck”, “Wagon”);
True/False - The following code would run without error.
proc print data=mydata;
where Age is not missing;
run;
True - You can check for missing values with the special operators IS MISSING or IS NOT MISSING. This code can be used for either numeric or character missing values.
How many unique values of Age will be included in the final report given the syntax below? proc print data=mydata; where Age between 20 and 30; run; a) 10 b) 11 c) 9 d) n/a - the code will error
b) 11
The BETWEEN AND operator is handy for numeric and character ranges. The endpoints of the ranges are inclusive.
True/False - The LIKE operator can be used in PROC SQL but not the DATA step.
False - the LIKE operator can be used in both steps
Which of the following is correct syntax for pattern matching with the LIKE operator?
a) where City like “New”;
b) where City like New;
c) where City like “New”;
d) where City like “New%”;
d) where City like “New%”;
The percent symbol is a wildcard for any number of characters and the underscore is a wildcard for a single character.
What will the following WHERE statement return? proc print data=mydata; where City like "Sant_ %"; run; a) Any Cities starting with "Sant" b) Any Cities starting with "Sant " c) Any Cities starting with "Sant", any single character value, space, and any string d) The program will error.
c) Any Cities starting with “Sant”, any single character value, space, and any string.
In this example, the underscore represents a single character and then a space and percent sign returns both Santa and Santo, a space, and any other string.
Which of the following are true regarding macro variables?
a) The SAS macro language is designed to help make your programs reusable and dynamic.
b) All statements in the macro language begin with a % sign, and the %LET statement creates a macro variable.
c) After %LET you specify the name of a macro variable, an equal sign, and then the text string you want to store.
d) You do not enclose the text string in quotation marks
e) All of the above.
e) All of the above.
True/False - The following program is the correct way to assign and reference a macro variable for CarType.
%LET CarType=Wagon;
proc print data=mydata;
where &CarType;
run;
False - The macro variable must be used as part of a conditional expression and since Type is character, the macro variable must be enclosed in quotes.
%LET CarType=Wagon;
proc print data=mydata;
where Type=”&CarType”;
run;
True/False - To control how values appear in your reports, you can apply a SAS format by adding the FORMAT option to your PROC step. For example:
proc print data=mydata
format mydate date9.;
run;
False - You must as the FORMAT statement. FORMAT is NOT an option.
proc print data=mydata;
format mydate date9.;
run;
Which of the following is true regarding the FORMAT statement?
a) You can only use one format within the FORMAT statement.
b) A & indicates a character format and precedes the name of the SAS format.
c) A period is a required delimiter for numeric formats, it can be followed by the number of decimal places
d) FORMATS applied to PROC steps permanently change the underlying data.
c) A period is a required delimiter for numeric formats, it can be followed by the number of decimal places.
No number after the decimal will round the column to the nearest whole number.
a) You can format any number of columns in a single FORMAT statement.
b) A $ dollar sign indicates a character format and precedes the name of the SAS format.
d) Formats impact the way values are displayed in the procedure results, they do not change the raw data values.
Given the raw value of 12345.67, which of the following will be displayed if you apply the 5. format to a PROC step?
a) 12345
b) 12345.6
c) 12,346
d) 12346
d) 12346 - The format indicate a width of 5 and no numbers following the decimal point indicate rounding to the nearest whole number.
Given the raw value 12345.67, which of the following formatted value is incorrect given the specified format?
a) comma8.1 - 12,345.7
b) dollar10.2 - $12,345.67
c) dollar10. - $12345.6
d) none of the above
c) dollar10. - $12345.6
The correctly formatted value is $12,346
True/False - For the COMMA and DOLLAR formats the width must accomodate the total width of the displayed value, including the dollar sign, commas, decimal point, and decimal places.
True
Which of the following are true regarding SAS formats?
a) Apply a format will automatically convert values from one currency to another.
b) The EUROX format, a euro symbol is inserted in the displayed value and decimal points and commas are transposed.
c) The YEN format rounds to the nearest whole number and adds the YEN symbol.
d) b and c
d) b and c
a) Formats do NOT convert values form one currency to another.
Given the raw value 21199, which of the following formatted value is incorrect given the specified format?
a) DATE7. - 15JAN18
b) DATE9. - 15JAN2018
c) MMDDYY10. - 01/15/18
d) MONYY7. - JAN2018
c) MMDDYY10. - The correctly displayed value is 01/15/2018
True/False - In a DATE format, you can control the display of a two- or four- digit year by adjusting the width.
True
Which of the following is NOT a SAS date format?
a) DDMMYYYY.
b) DDMMYY.
c) DAY.
d) YEAR.
e) YYMM.
a) DDMMYYYY.