1.3 & 1.4 Flashcards

1
Q

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

A

d) PROC CONTENTS

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

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

A

c) PROC UNIVARIATE

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

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

A

f) cumulative total

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

True/False - PROC MEANS procedure includes detailed statistics related to distribution.

A

False - PROC UNIVARIATE includes more detailed statistics related to distribution than PROC MEANS

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

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;

A

c) proc print data=pg1.storm_summary (obs=10);

run;

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

True/False - The following procedure will run without error.

proc freq data=pg1.storm_summary;
var Basin Type Season;
run;

A

False - PROC freq uses the tables statement, not var.

proc freq data=pg1.storm_summary;
tables Basin Type Season;
run;

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

True/False - The PROC UNIVARIATE procedure can be used to identify case inconsistencies and incorrect values.

A

False - PROC FREQ can be used to identifies case inconsistencies and incorrect values.

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

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

A

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.

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

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

A

e) != or NE

b) ^= or ~= or NE : these are the correct ways to specify not equal

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

True/False - When specifying expressions character values are case sensitive.

A

True

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

True/False - When specifying expressions numeric values can include special characters.

A

False - they must be standard numeric values. You cannot include special symbols such as commas or dollar signs.

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

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;

A

c) where Type=”SUV” and MSRP <= 30000;

You can combine multiple expressions with the keywords AND or OR in a WHERE statement.

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

True/False - The IN operator only works with character values.

A

False - The IN operator works with both numeric and character values. Character values are case sensitive and must be enclosed in quotation marks.

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

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

a) where Type not in (“SUV”, “Truck”, “Wagon”);

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

True/False - The following code would run without error.
proc print data=mydata;
where Age is not missing;
run;

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
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
A

b) 11

The BETWEEN AND operator is handy for numeric and character ranges. The endpoints of the ranges are inclusive.

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

True/False - The LIKE operator can be used in PROC SQL but not the DATA step.

A

False - the LIKE operator can be used in both steps

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

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%”;

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
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.
A

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.

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

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.

A

e) All of the above.

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

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;

A

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;

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

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;

A

False - You must as the FORMAT statement. FORMAT is NOT an option.

proc print data=mydata;
format mydate date9.;
run;

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

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.

A

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.

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

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

A

d) 12346 - The format indicate a width of 5 and no numbers following the decimal point indicate rounding to the nearest whole number.

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

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

A

c) dollar10. - $12345.6

The correctly formatted value is $12,346

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

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.

A

True

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

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

A

d) b and c

a) Formats do NOT convert values form one currency to another.

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

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

A

c) MMDDYY10. - The correctly displayed value is 01/15/2018

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

True/False - In a DATE format, you can control the display of a two- or four- digit year by adjusting the width.

A

True

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

Which of the following is NOT a SAS date format?

a) DDMMYYYY.
b) DDMMYY.
c) DAY.
d) YEAR.
e) YYMM.

A

a) DDMMYYYY.

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

True/False - The following is correct syntax for sorting a data set by descending Age.

proc sort data=mydata;
by descending Age;
run;

A

True;

PROC SORT DATA=input-table ;
BY col-name(s);
RUN;

32
Q

Which of the following statements is true regarding the PROC SORT procedure?

a) By default SAS sorts in descending order.
b) You can sort on one or more character or numeric columns in one PROC SORT step
c) The OUT= option is required for all PROC SORT STEPS
d) The BY statement is optional, if unspecified SAS will sort all columns in order.

A

b) You can sort on one or more character or numeric columns in one PROC SORT step

a) By default SAS sorts in ascending order
c) The OUT= option is optional, if not specified SAS will sort the rows of the input table
d) The BY statement must be included in every PROC SORT

33
Q

Which of the following is NOT true regarding eliminating duplicate values in a PROC SORT statement?

a) The NODUPKEY option removes adjacent duplicated values for the columns you specify on the BY statement.
b) When you add the NODUPKEY option to the PROC SORT statement, only the first occurrence for each unique value of the column listed in the By statement is kept in the output table.
c) Use the keyword ALL in the BY statement to find and remove entirely duplicated rows.
d) The DUPOUT= option is the new table without duplicates

A

d) THE OUT= option is the new table without duplicates.

The DUPOUT= option contains the duplicate rows that were removed by NODUPKEY.

34
Q

True/False - The following code will eliminate entirely duplicated rows in the pg1.class_test2 data set?

proc sort data=pg1.class_test2
                out=test_clean
                dupout=test_dups
                nodupkey;
    by Name;
run;
A

False - The pg1.class_test2 data set will be unchanged. The output table, test_clean, will have rows with duplicate values of the Name column removed.

35
Q
Which of the following procedure syntax is NOT correct?
a) PROC PRINT DATA=input-table (OBS=n);
             VAR col-name(s);
    RUN;
b) PROC MEANS DATA=input-table;
             VAR col-name(s);
    RUN;
c) PROC UNIVARIATE DATA=input-table;
            VAR col-name(s);
    RUN;
d) PROC FREQ DATA=input-table  ;
            TABLES col-name(s);
    RUN;
A

d) Correct syntax is:
PROC FREQ DATA=input-table ;
TABLES col-name(s) ;
RUN;

36
Q

True/False - The WHERE statement is used to filter rows. It reads all rows and evaluates whether the expression in the WHERE statement is true or false.

A

FALSE - If the expression is true, rows are read If the expression is false, they are not.

37
Q

Which of the following is not appropriate SAS date constant syntax?

a) “01JAN2021”d
b) “01MARCH20”d
c) “01aug1980”
d) “01aug1980”d
e) b and c

A

e) b and c
The SAS date constant syntax: “ddmmmmyyyy”d, where dd represents a 1- or 2- digit day, mmm represents a 3-letter month in any case, yyyy represents a 2- or 4- digit year.

38
Q

Which of the following is not an appropriate usage of a macro variable ?

a) WHERE numvar=&macrovar;
b) WHERE charvar=”&macrovar”;
c) WHERE datevar=”&macrovar”d;
d) WHERE datevar=&macrovar

A

d) c is the correct syntax

39
Q

Which of the following correctly creates a mychar macro?

a) %LET macro-variable=value;
b) %LET &macro-variable=value;
c) %LET macro-variable=”value”;
d) %LET macro-variable=&value;

A

a) The %LET statement defines the macro variable name and assigns a value.

40
Q

Which of the following is true regarding macro variables?

a) A macro variable stores a text string that can be substituted into a SAS program
b) Macro variable names must follow SAS naming rules
c) Macro variables can be referenced in a program by preceding the macro variable name with an &
d) If a macro variable reference is used inside quotation marks, double quotation marks must be used.
e) All of the above

A

e) All of the above

41
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) 1
b) 3
c) 5
d) 6

A

b) 3

42
Q

Which of the following FORMAT statements was used to create this output?

OBS Order_Date Delivery_Date
1 11JAN07 01/11/07

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

A

b) format Order_Date date7. Delivery_Date mmddyy8.;

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.

43
Q

True/False - The format name must include a period delimiter in the FORMAT statement.

A

True

44
Q

Which of the following row or rows will be selected by the following WHERE statement?

where Job_Title like “Sales%”;

Obs Job_Title
1 Sales Rep I
2 Sales Manager
3 Insurance Sales

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

A

d) row 1 and 2

45
Q

Which statement about this PROC SORT step is true?

proc sort data=orion.staff;
out=workstaff;
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 Manger_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.

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.

46
Q

Which of the 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’);

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.

47
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

48
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;

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.

49
Q

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

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

A

c) VAR

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.

50
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) PRINT
b) MEANS
c) UNIVARIATE
d) FREQ

A

d) FREQ

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

51
Q

Which of the following is NOT a SAS function that you can use to manipulate character columns?

a) UPCASE(char)
b) LOWCASE(char)
c) PROPCASE(char, )
d) MEAN(col-1, col-2,…col-n)
e) CATS(char1, char2, …)

A

d) MEAN(col-1, col-2,…col-n)

52
Q

Which of the following arguments are required for the SUBSTR character function, list all that apply?

a) length
b) char
c) position
d) delimiter

A

b and c

SUBSTR(char, position, )

53
Q
Which of the following following would be printed to the log in the DATA step?
data _null_;
  x="My cat Onyx ";
  y=" is black";
  z=".';
 results=cats(x, y);
 put results $char.;
run;

a) My cat Onyx is black
b) My cat Onyxis black
c) My cat Onyx is black
d) My cat Onyx is black.

A

b) My cat Onyxis black

The CATS function removes leading and trailing blanks, and returns a concatenated character string.

54
Q

Which of the following is true regarding the PROPCASE function?

a) it changes letters in a character string to uppercase or lowercase
b) it changes the first letter of each word to uppercase and other letters to lowercase
c) it returns a substring from a character string
d) it is a numeric, not a character function

A

b) it changes the first letter of each word to uppercase and other letters to lowercase

55
Q

Which of the following is false?

a) the MONTH(SAS-date) function returns a number from 1 through 12 that represents the month
b) the YEAR(SAS-date) function returns the four-digit year
c) DAY(SAS-date) function returns the day of the week in character format (e.g. Monday, Tuesday, Wednesday, etc.)
d) QTR(SAS-date) Returns a number from 1 through 4 that represents the quarter.

A

c) DAY(SAS-date) function returns the day of the week in character format (e.g. Monday, Tuesday, Wednesday, etc.)

This function returns a number from 1 through 31 that represents the day of the month.

WEEKDAY(SAS-date) Returns a number from 1 through 7 that represents the day of the week (Sunday=1).

56
Q

True/False - The TODAY() function returns the current date as a numeric SAS date value (no argument is required because the function reads the system clock).

A

True

57
Q

Which of the functions below returns a SAS date value from numeric month, day, and year values?

a) MMDDYY(month, day, year)
b) MDY(month, day, year)
c) MDY(SAS-date)
d) DATE(SAS-date)

A

b) MDY(month, day, year)

58
Q

What does the YRDIF(startdate, enddate, ‘AGE’) function do?

a) Calculates the precise age between two dates
b) Calculates the number of years between two years
c) Returns the first date of the current year in SAS date format
d) Returns the maximum date in a column of dates

A

a) Calculates the precise age between two dates

YRDIF(startdate, enddate, ) - basis identifies a character constant or variable that describes how SAS calculates a date difference of a person's age.  Valid values include:
'30/360'
'ACT/ACT'
'ACT/360'
'ACT/365'
'AGE'
59
Q

Which of the following is true regarding multiple IF-THEN conditions?

a) By default the statement that executes on the first true condition determines the value in the output table.
b) The ELSE condition tells SAS to test the conditions only until a true expression is found.
c) You cannot use compound conditions in SAS, each condition must be its own statement.
d) a & b

A

b) The ELSE condition tells SAS to test the conditions only until a true expression is found.

a - When you have multiple IF-THEN statements, SAS tests all the conditions in sequence for every row in the data. The statement that executes on the last true condition determines the value in the output table.
c - You can create compound conditions with AND or OR.

60
Q

True/False - The columns in an output table are defined in the compilation phase of the DATA step.

A

True

61
Q
What would be the length of the new field CarType given the DATA step below?
data cars2;
   set sashelp.cars;
   if MSRP<60000 then CarType="Basic";
   else CarType="Luxury";
  keep Make Model MSRP CarType;
run;

a) 6
b) 8
c) 5
d) unknown

A

c) 5

The first assignment statement defines a character column and assigns the value Basic, so SAS creates a column named CarType with a length of 5, the number of characters in the work Basic. The word LUXURY is truncated because it has six characters. One way to avoid this problem is to explicitly define a character column in the DATA step with a LENGTH statement.

62
Q

What syntax do you need to use in order to execute multiple statements after the keyword THEN, when using IF-THEN conditions?

a) Use a compound keyword - AND or OR
b) List each statement to execute in a separate IF-THEN statement
c) Add a & between statements
d) Use IF-THEN/DO syntax.

A

d) Use IF-THEN/DO syntax.

63
Q

True/False - The DATA step below will successfully execute multiple statements.

data under40;
    set sashelp.cars;
    if MSRP < 20000 then do Cost_Group=1;
        output under40;
    end;
   else if MSRP < 40000 then do Cost_Group=2;
       output under40;
run;
A

False - missing a ; after do keyword. Correct syntax is:

data under40;
    set sashelp.cars;
    if MSRP < 20000 then do;
        Cost_Group=1;
        output under40;
    end;
   else if MSRP < 40000 then do;
       Cost_Group=2;
       output under40;
run;
64
Q

All of the following can be done in a SAS DATA step EXCEPT:

a) Creating a copy of data
b) Filtering rows in the DATA step
c) Importing Excel file with column names that following SAS naming conventions.
d) Specifying columns to include in the output data set.
e) Formatting columns.

A

c) This is done in a global OPTIONS statement.

65
Q

True/False - The following syntax will correctly specify the length of a character column.

LENGTH char-column $ length;

A

True

66
Q

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

a) compilation
b) execution

A

a) compilation

67
Q

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

a) DATA statement
b) WHERE statement
c) SET statement
d) assignment statement

A

c) SET statement

68
Q

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

A

False - You can use the XLSX LIBNAME engine to read and Excel worksheet directly and process the data with the DATA step.

69
Q

What is the name of the output 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

b) work.us

The output table is listed in the DATA statement.

70
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

71
Q

Given 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
1 2 3 4

a) 4
b) 8
c) .
d) The statement generates a syntax error.

A

b) 8

72
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)

73
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

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

74
Q

What is the length of the Car_Type column created in this program?

data car_type;
   set sashelp.cars;
   if msrp > 8000 then car_type="luxury";
   else car_type="regular";
   length car_type $ 8;
run;

a) 6
b) 7
c) 8

A

a) a

When the DATA step is complied, 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.

75
Q

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

A

True