Ch 12: SAS Formats and Informats Flashcards

1
Q
Suppose you do not specify the LIBRARY= option and your formats are stored in Work.Formats. How long do they exist?
a.
only for the current procedure
b.
only for the current DATA step
c.
only for the current SAS session
d.
permanently
A

Correct answer: c
If you do not specify the LIBRARY= option, formats are stored in a default format catalog named Work.Formats. The libref Work signifies that any format that is stored in Work.Formats is a temporary format; it exists only for the current SAS session.

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

Which of the following statements store your formats in a permanent catalog?
a.
libname formtlib ‘C:\Users\Student1\sas\formats\lib’;
proc format lib=formtlib
…;
b.
libname formtlib ‘C:\Users\Student1\sas\formats\lib’;
format lib=formtlib
…;
c.
formtlib=’C:\Users\Student1\sas\formats\lib’;
proc format formtlib
…;
d.
formtlib=’C:\Users\Student1\sas\formats\lib’;
proc formtlib
…;

A

Correct answer: a
To store formats in a permanent catalog, you first write a LIBNAME statement to associate the libref with the SAS data library in which the catalog will be stored. Then add the LIB= (or LIBRARY=) option to the PROC FORMAT statement, specifying the name of the catalog.

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

When you create a format with the VALUE statement, the new format’s name cannot end with a number, cannot end with a period, and cannot be the name of a SAS format. Which of the following is also true?
a.
The name cannot be the name of a data set variable.
b.
The name must be at least two characters long.
c.
The name must be at least eight characters long.
d.
The name must begin with a dollar sign ($) if used with a character variable.

A

Correct answer: d
The name of a format that is created with a VALUE statement must begin with a dollar sign ($) if it applies to a character variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
Which of the following FORMAT procedures is written correctly?
a.
proc format lib=formtlib
value colorfmt;
1='Red'
2='Green'
3='Blue'
run;
b.
proc format lib=formtlib;
value colorfmt
1='Red'
2='Green'
3='Blue';
run;
c.
proc format lib=formtlib;
value colorfmt;
1='Red'
2='Green'
3='Blue'
run;
d.
proc format lib=formtlib;
value colorfmt
1='Red';
2='Green';
3='Blue';
run;
A

Correct answer: b
A semicolon is needed after the PROC FORMAT statement. The VALUE statement begins with the keyword VALUE and ends with a semicolon after all the labels have been defined.

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

Which of these statements is false regarding what the ranges in the VALUE statement can specify?
a.
They can specify a single value, such as 24 or ‘S’.
b.
a range of numeric values, such as 0-1500.
c.
a range of character values, such as ‘A’-‘M’.
d.
a list of numeric and character values separated by commas, such as 90,’B’, 180,’D’,270.

A

Correct answer: d
You can list values separated by commas, but the list must contain either all numeric values or all character values. Data set variables are either numeric or character

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
How many characters can be used in a label?
a.
96
b.
200
c.
256
d.
32,767
A

Correct answer: d

When specifying a label, enclose it in quotation marks and limit the label to 32,767 characters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
Which keyword can be used to label missing numeric values as well as any values that are not specified in a range?
a.
LOW
b.
MISS
c.
MISSING
d.
OTHER
A

Correct answer: d
MISS and MISSING are invalid keywords, and LOW does not include missing numeric values. The keyword OTHER can be used in the VALUE statement to label missing values as well as any values that are not specifically included in a range.

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

You can place the FORMAT statement in either a DATA step or a PROC step. What happens when you place it in a DATA step?
a.
You temporarily associate the formats with variables.
b.
You permanently associate the formats with variables.
c.
You replace the original data with the format labels.
d.
You make the formats available to other data sets.

A

Correct answer: b

By placing the FORMAT statement in a DATA step, you permanently associate the defined format with variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
Suppose the format JOBFMT was created in a FORMAT procedure. Which FORMAT statement applies it to the variable JobTitle in the program output?
a.
format jobtitle jobfmt;
b.
format jobtitle jobfmt.;
c.
format jobtitle=jobfmt;
d.
format jobtitle='jobfmt';
A

Correct answer: b
To associate a user-defined format with a variable, place a period at the end of the format name when it is used in the FORMAT statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
Which keyword, when added to the PROC FORMAT statement, displays all the formats in your catalog?
a.
CATALOG
b.
LISTFMT
c.
FMTCAT
d.
FMTLIB
A

Correct answer: d
Adding the keyword FMTLIB to the PROC FORMAT statement displays a list of all the formats in your catalog, along with descriptions of their values.

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