Midterm 1 Flashcards

1
Q

The Data Step

A

The data step manipulates the data.
The input for a data step can be of several types, such as raw data or a SAS data set.
The output from a DATA step can be of several types, such as a SAS data set or a report.

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

Do all SAS programs contain a DATA step?

A

No

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

PROC step

A

In general, the PROC step analyzes data, produces output, or manages SAS files.
The input for a PROC step is usually a SAS data set.
THe ouput from a PROC step can be of several types, such as a report or an updated SAS data step.

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

SAS Statements

A

A SAS statement is a series of items that might include keywords, SAS names, special characters, and operators.
The two types of SAS statements are:
Those that are used in DATA and PROC steps.
Those that are global in scope and can be used anywhere in a SAS program
All SAS statements end with a semicolon.

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

Global statements

A

Used anywhere in a SAS program.
Stay in effect until changed or canceled, or until you end your SAS session.
i.e. TITLE, OPTIONS, FOOTNOTE

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

SAS data sets

A

SAS file store in a SAS library that SAS creates and processes.
Contains data values that are organized as a table of observations (rows) and variables (columns)
Contains descriptor information such as the data types and lengths of the variables.

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

SAS libraries

A

A collection of one or more SAS files, including SAS data sets, that are referenced and stored as a unit.
A logical name (libref) can be assigned to a SAS library using the LIBNAME statement

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

Libref

A

A libref can be up to 8 characters long.
must begin with a letter or an underscore.
can contain only letters, digits, or underscores.
i.e. libname project ‘C:\workshop\winsas\lwcrb’;

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

Which of the following sentences is true concerning the LIBNAME statement:
A. The LIBNAMEstatement must go in a DATAstep.
B. The LIBNAMEstatement must end in a semicolon.
C. The LIBNAME statement must be the first statement in a program.
D. The LIBNAME statement must be followed by the RUN statement.

A

B. The LIBNAMEstatement must end in a semicolon.

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

Two-level SAS data set name

A

A SAS data set can be referenced using a two level SAS data set name: libref.dataset
i.e. proc sort data=work.enroll
libref is the logical name that is associated with the physical location of the SAS library.
data set is the data set name, which can be up to 32 characters long, must begin with a letter or an underscore, and can contain letters, digits, and underscores.

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

One-level SAS data set name

A

A data set referenced with a one level name is automatically assigned to the work library by default.
i.e. proc sort data=enroll out=project.enroll;

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

Temporary SAS Data sets

A

A temporary SAS dat set is one that exists only for the current SAS session or job.
The work library is a temporary data library.
Data sets held in the Work library are deleted at the end of the SAS session.

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

Permanent SAS data sets

A

A data set that resides on the external storage medium of your computer and is not deleted when the SAS session terminates.
Any data library referenced with a LIBNAME statement is considered a permanent data library by default.

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

Variables

A

Data values are organized into columns called variables.
Variables have attributes, such as the name and type, that enable you to identify them and that define how they can be used.

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

Variable names

A

Variable names can be up to 32 characters long
Must begin with a letter or an underscore.
Can contain only letters, digits, or underscores.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
Which of the following variable names is valid?
A. street#
B. zip_code
C. 2address
D. last name
A

B. zip_code

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

Character variables

A

Character variables are stored with a length of 1 to 32,767 bytes with 1 character equaling 1 byte.
Character variables can contain letters, numeric digits, and other special characters.

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

Numeric variables

A

Numeric variables are stored as floating-point numbers with a default byte size of 8.
To be stored as a floating point number, the numeric value can contain numeric digits, plus or minus sign, decimal point, and E for scientific notation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
How many of the following data sets aren't permanent data sets?
work.enroll
temp.enroll
project.enroll
enroll
A

Two (work.enroll and enroll)

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

How should a date be stored in SAS?

a. character
b. numeric

A

b. numeric

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

SAS Dates

A

A SAS date value is a value that represents the number of days between January 1, 1960, and a specified date.
Dates before January 1, 1960 are negative numbers.
Dates after January 1, 1960, are positive numbers.
To reference a SAS date value in a program, use a SAS date constant.
A SAS date constant is a date (DDMMMYYYY) in quotation marks followed by the letter D.
ex. ‘12NOV1986’d

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q
What is the numeric SAS date value for December 25, 1959?
A. -6
B. -7
C. 6
D. 8
A

B. -7

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

Missing Data

A

Missing data is a vlaue that indicates that no data value is stored for the variable in the current observation.
A missing numeric value is displayed as a single period (.)
A missing character value is displayed as a blank space.

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

CONTENTS procedure

A

The contents procedure shows the descriptor portion of a SAS data set.
i.e. proc contents data=project.enroll; run;
the VARNUM option can be used to print the variable list in the order of the variables’ potions in the data set.

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

Which step displays the director of the project library and suppresses printing the contents of individual data sets?
A. proc contents data=project; run;
B. proc contents data=project.all;
C. proc contents data=project nocontents; run;
D. proc contents data=project._all_nods; run;

A

D. proc contents data=project._all_nods; run;

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

PRINT Procedure

A

The print procedure can show the data portion of a SAS data set.
ex. proc print data=project.enroll; run;

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

Comments

A

Two ways to add comments:
comment
/
comment */

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

What is the name of the data set being read?
data work.newprice;
set golf.supplies;

A

golf.supplies

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

What is the name of the data set being created?
data work.newprice;
set golf.supplies;

A

work.newprice

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

Set statement

A

The SET statement reads an observation from one or more SAS data sets for further processing in the DATA step.
By default, the SET statement reads all variables and all observations from the input data sets.
The set statement can read temporary or permanent data sets.

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

Compilation phase

A

During the compilation phase, SAS does the following:
Checks the syntax of the SAS statements.
Translates the statements into machine code.
Identifies the name, type, and length of each variable.

The following three items are potentially created:
input buffer
program data vector
descriptor information

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

Input Buffer

A

The input buffer is a logical area in memory into which SAS reads each record of a raw data file when SAS executes an INPUT statement.
This buffer is created on when the DATA step reads raw data
When the data step reads a SAS data set, SAS reads the data directly into the program data vector.

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

Program Data Vector (PDV)

A

A logical area in memory where SAS builds a data set, one observation at a time.

Along with data set variables and computed variables, the PDV contains the following two automatic variables:

  • the _N- variable, which counts the number of times the DATA step begins to iterage.
  • the ERROR variable, which signalas the occurrence of an error caused by the data during execution. Either 0 (no error) or 1 (one or more errors occured)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

Which of the following statements is false concerning the N and ERROR variables?
A. SAS does not write the N and ERROR variables to the output data set.
B. SAS increments the N variable by 1 for each iteration of the DATA step.
C. SAS automatically generates the N and ERROR variables for every DATA step.
D. SAS sets the ERROR variable equal to the total number of errors caused by the data during execution

A

D. SAS sets the ERROR variable equal to the total number of errors caused by the data during execution

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

Which one of the following is not one of the items in the PDV at compile time?
A. byte size of the variable
B. Initial value of the variable.
C. Name of the variable
D. type (character or numeric of the variable

A

B. Initial value of the variable.

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

Descriptor information

A

Information that SAS creates and maintains about each SAS data set, including data set attributes and variable attributes.
I.e. name of the data set, date and time that the data set was created, names data types, and lengths of the variables.

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

Execution Phase

A

During the execution phase, SAS does the following:

  • Initializes the PDV to missing and sets the initial values of N and ERROR
  • Reads data values into the PDV
  • Executes any subsequent programming statements
  • Outputs the observation to a SAS data set
  • Returns to the top of the DATA step
  • Resets the PDV to missing for any variables not read directly from a data set and increments N by 1
  • repeats the process until the end of file is detected.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

How many times does SAS iterate through a DATA step with 9 observations?

A

Nine times

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

DROP statement

A

the DROP statement specifies the names of the variables to omit from the output data set.

Use DROP= after data-set input name to specify the variables for writing to a specific output data set.

data work.total(keep=name total test1 test2)

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

KEEP statement

A

The KEEP statement specifies the names of the variable to write to the output data set.

Use KEEP= after data-set input name to specify the variables for writing to a specific output data set.

data work.total(drop=name total test1 test2)

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

FORMAT Statements

A
The FORMAT statement associates formats to variable values.
ex.
data work.newprice;
set golf.supples;
saleprice=price*0.75;
format saleprice dollar18.2;
run;
Format statements assigned in a DATA step are considered permanent attributes (stored in the descriptor portion).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

LABEL Statements

A

The LABEL statement assigns descriptive labels to variable names.
data work.newprice;
set golf.supples;
saleprice=price*0.75;
label type=’Type of Ball’ saleprice=’Sale Price’
run;
Label statements assigned in a DATA step are considered permanent attributes (stored in the descriptor portion).

43
Q

How is the DATA step debugger invoked?
A. adding a /DEBUG option to the DATA statement
B. adding a DEBUG statement after the DATA statement.
C. adding the DEBUG option to the OPTIONS statement
D. adding the DEBUG=YES option to the OPTIONS statement

A

A. adding a /DEBUG option to the DATA statement

44
Q

DATA step debugger

A

The DATA step debugger consists of windows and a group of commands that provide an interactive way to identify logic and data errors in DATA steps.

45
Q

PUTLOG Statement

A

The PUTLOG statement can be used to write messages to the SAS log to help identify logic errors.

46
Q

Implicit Output

A

By default, at the end of each iteration, every DATA step contains an implicit OUTPUT statement that tells SAS to write observations to the data set or data sets that are being created.

47
Q

OUTPUT Statement

A

The OUTPUT statement without arguments causes the current observation to be written to all data sets that are named in the DATA statement.
Multiple output statements can be used in a data step.
Placing an explicit OUTPUT statement in a DATA step overrides the implicit output, and SAS adds an observation to a data set only when an explicit OUTPUT statement is executed.

48
Q

Creating multiple data sets

A
The DATA statement can specify multiple output data sets.
The OUTPUT statement can specify the data set names.
data work.first work.second;
set work.scores;
test=test1;
output work.first;
test=test2;
output work.second;
drop test1 test2;
run;

Using the OUTPUT statement without arguments causes the current observation to be written to all data sets that are named in the DATA statement.
The drop and keep statements apply to all output data sets.

49
Q
Which data set(s) does the OUTPUT statement populate?
data work.total work.first work.second;
set work.scores;
total=test1+test2;
output;
run;

A. work.total
B. work.first
C. work.second
D. work.total, work.first, and work.second

A

D. work.total, work.first, and work.second

50
Q

OUTPUT statements and if-then statement

A

Ex. if sex=’F’ then output female;

else if sex=’M’ then output male;

51
Q

Selecting Observations

A

The FIRSTOBS= and OBS= data set options can be used to control which observations are read from the input data set.
ex. set sashelp.retail (obs=10);
FIRSTOBS= and OBS= are valid for input processing only. They are not valid for ouput processing.

52
Q
How many observations are in the output data set?
data work.portion;
set sashelp.retail (firstobs=5 obs=10);
run;
A. 5
B. 6
C. 10
D. 14
A

B. 6

53
Q

FIRSTOBS=

A

the FIRSTOBS= data set option specifies a starting point for processing an input data set.

54
Q

OBS=

A

the OBS= data set option specifies an ending point for processing an input data set.
The OBS= option specifies the number of the last observation, and not how many observations there are to process.

55
Q

Which step has invalid syntax?
A. data shoes (firstobs=101 obs=200);
set sashelp.shoes; run;
B. data shoes;
set sashelp.shoes (firstobs=101 obs=200); run;
C. proc print data=sashelp.shoes (firstobs=101 obs=200); run;

A

A. data shoes (firstobs=101 obs=200);

set sashelp.shoes; run;

56
Q

Expression

A

An expression is a sequence of operands and operators that forms a set of instructions that define a condition for selecting observations.

operands are constants (character or numeric), variables (character or numeric), SAS functions

operators are symbols that request a comparison, logical operation, or arithmetic calculation.

57
Q

Comparison operators

A

Comparison operators compare a variable with a value or with another variable.

EQ or =: equal to
NE or ^= ~= : not equal to
GT or >: greater than
GE >=: greater than or equal to
LT or
58
Q
Which of the following is not a valid expression?
A. qtr1<= qtr2
B. address=' '
C. sales gt 6400
D. name ne Mary Ann
A

D. name ne Mary Ann

59
Q

Logical operators

A

Logical operators combine or modify expressions
AND or &: logical and
OR or |: logical or
NOT or ^: logical not

60
Q

Arithmetic operators

A

Arithmetic operators indicate that an arithmetic calculation is performed.
If a missing value is an operand for an arithmetic operator, the result is a missing value.
**: exponentiation
*: multiplication
/: division
+: addition
-: subtraction

61
Q

Special WHERE operators

A
The WHERE statement can use special WHERE operators
BETWEEN - AND : an inclusive range
CONTAINS or ? : a character string
LIKE: a character pattern
SOUNDS LIKE or =* : spelling variation
IS NULL : missing value
IS MISSING : missing value
SAME AND ALSO : augments and expression
62
Q

Which names will be selected based on the below expression?

name like ‘M_ _k’%

  1. Mark
  2. Marcia
  3. Mickey
  4. Matthew
  5. Michael
A
  1. Mark

3. Mickey

63
Q

data work.newprice;
set golf.supplies;
saleprice=price*0.75;
run;

Which statement must be added to the above program to create an output data set with observations having saleprice greater than $10?

A. if not (saleprice>10) then delete;
B. if saleprice>10;
C. either statement will work.

A

C. Either statement will work

64
Q

data work.newprice;
set golf.supplies;
saleprice=price*0.75;
run;

Which statement must be added to the above program to create an output data set with observations having saleprice greater than $10?

A. where saleprice>10;
B. if saleprice>10;
C. either statement will work.

A

B. if saleprice>10;

65
Q

WHERE Statement

A

The WHERE statement causes the DATA step to process only those observations from a data set that meet the condition of the expression.
The expression in the WHERE statement
Can reference variables that are from the input data set.
Cannot reference variables created from an assignment statement or automatic variables (N or ERROR).

66
Q

data subset;
set sales;
difference=actual-predict;

run;

Which WHERE statement will create an error when submitted, if inserted in the above program?
A. where actual>predict;
B. where difference ge 1000;
C. where product in ('CHAIR' , 'SOFA');
D. where state='Texas' and date
A

B. where difference ge 1000;

67
Q

Subsetting if statement

A

The subsetting if statement causes the DATA step to continue processing only those observations in the program data vector that meet the condition of the expression.
data work.newprice;
set golf.supplies;
saleprice=price*0.75;
if saleprice>10;
run;
If the expression is true for the observation, SAS continues to execute the remaining statements in the DATA step, including the implicit OUTPUT statement at the end of the DATA step. The resulting SAS data set (or data sets) contains a subset of the original SAS data set.
If the expression is false, no further statements are processed for that observation, the current observation is not written to the DATA step are not executed, and SAS immediately returns to the beginning of the DATA step.

68
Q
Which program will create an error when submitted?
A. data subset;
set sales;
if difference<500;
difference=actual-predict;
if state= 'Texas';
run;
B. data subset;
set sales;
differences=actual-predict;
if difference between 500 and 1000;
run;
C. data subset;
set sales;
difference=actual-predict;
if product='CHAIR' and difference ge 100;
run;
A
B. data subset;
set sales;
differences=actual-predict;
if difference between 500 and 1000;
run;
69
Q

WHERE statement versus subsetting IF statement

A

The WHERE statement selects observations before they are brought into the program data vector.
The subsetting IF statement selects observations that were read into the program data vector.

70
Q

IF-THEN DELETE Statement

A

The IF-THEN DELETE statement causes the DATA step to stop processing those observations in the program data vector that meet the condition of the expression.

ex. if saleprice<= 10 then delete;

If the expression is true for the observation, the current observation is not written to a data set, and SAS returns immediately to the beginning of the DATA step for the next iteration.

71
Q

SORT Procedure

A

Orders SAS data set observations by the values of one or more character or numeric variables
Either replaces the original data set or creates a new data set.
Produces only an output data set, but no report.
Arranges the data set by the values in ascending order by default.
The DATA= option identifies the input SAS data set.
The OUT= option names the output data set.
Without the OUT= option, the SORT procedure overwrites the original data set.
ex. proc sort data=sashelp.shoes
out=shoes;
by descending region product;
run;

72
Q

BY statement

A

The BY statement specifies the sorting variables.
PROC SORT first arranges the data set by the values of the first BY variable
PROC SORT then arranges any observations that have the same value of the first BY variable by the values of the second BY variable.
This sorting continues for every specified BY variable.
By default, the SORT procedure orders the values by ascending order.
The DESCENDING option reverses the sort order for the variable that immediately follows in the statement.
In addition ot the SORT procedure, a BY statement can be used in the DATA step and other PROC steps.
The data sets used in the DATA step and other PROC steps must be sorted by the values of the variables that are listed in the BY statement or have an appropriate index.

73
Q
Will the following program run successfully?
proc sort data=sashelp.shoes
out=shoes;
by descending region ascending product;
run;
A

No

74
Q

Concatenating

A

If more than one data set name appears in the SET statement, the resulting output data set is a concatenation of all the data sets that are listed.
SAS reads all observations from the first data set, then all from the second data set, and so on, until all observations from all the data sets are read.

75
Q

LENGTH Statement

A
The LENGTH statement specifies the number of bytes for storing variables.
EX. data company;
length name $ 15;
set divisionA divisionB;
run;
76
Q

Will you get the same results if the LENGTH statement is after the SET statement?

A

No

77
Q

RENAME=

A

The RENAME= data set option changes the names of variables.
The RENAME= option specifies the variable that you want to rename equal to the new name of the variables
The list of variables to rename must be enclosed in parentheses.
Ex. set divisionA (rename=(state=location)) divisionB;

78
Q
Which of the following statements has the proper syntax for the RENAME= option?
A. set divisionA (rename=name=first, state=location)
division B (rename=name=first);
B. set divisionA (rename=(name=first state=location))
divisionB (rename=(name=first);
C. set divisionA (rename= (name=first) (state=location))
divisionB (rename= (name=first));
D. set divisionA (rename= (name=first), (state=location))
divisionB (rename = (name=first));
A

B. set divisionA (rename=(name=first state=location))

divisionB (rename=(name=first);

79
Q

Interleaving

A

Use a single SET statement with multiple data sets and a BY statement to interleave the specified data sets.
The observations in the new data set are arranged by the values of the BY variable or variables. Then, within each BY group, they are arranged by the order of the data sets in which they occur.

The data sets that are listed in the SET statement must be sorted by the values of the variables that are listed in the BY statement, or they must have an appropriate index.

data company;
length name $ 15;
set divisionA (rename=(state=location))
divisionB;
by name;
run;
80
Q

Merging

A

The merge statement joins observations from two or more SAS data sets into single observations.
The BY statement specifies the common variables to match-merge observations. The variables in the BY statement must be common to all data sets.
The data sets listed in the MERGE statement must be sorted in the order of the values of the variables that are listed in the BY statement, or they must have an appropriate index.

Ex. data combine;
merge revenue expense;
by name;
profit=revenue-expense;
run;
81
Q

IN= Option

A

The IN= option creates a variable that indicates whether the data set contributed data to the current observation.
Within the DATA step, the value of the variable is 1 if the data set contributed to the current observation, and 0 if the data set did not contribute to the current observation.

Ex. data combine1;
merge revenue1 (in=rev)
expense1 (in=exp);
by name;
profit=revenue-expense;
run;
82
Q

Which of the following statements is false concerning the IN= option?
A. The IN= variables are included in the SAS data set that is being created.
B. The values of the IN= variables are available to program statements during the DATA step.
C. when a data set contributes an observation for the current BY group, the IN= value is a numeric 1.
D. The IN= data set option is specified in parentheses after a SAS data set name in the SET and MERGE statements.

A

A. The IN= variables are included in the SAS data set that is being created.

83
Q
data combine1;
merge revenue1 (in=rev)
expense1 (in=exp);
by name;
profit=revenue-expense;
run;

Which statement will give all observations from the revenue1data set regardless of matches or non matches?
A. if rev=1;
B. if rev=1 and exp=1;
C. if rev=1 and (exp=1 and exp=0)
D. if (rev=1 and exp=1) and (rev=1 and exp=0)

A

A. if rev=1;

84
Q

INFILE Statement

A
With an INPUT statement, the INFILE statement identifies the physical name of the external file to read.
The physical name is the name that the operating environment uses to access file.
EX. 
data work.kids;
infile 'kids.dat';
input name $ 1-8 siblings 10
@12 bdate mmddyy10.
@23 allowance comma2.
hobby1 $ hobby2 $ hobby3 $;
run;
85
Q

INPUT statement

A

The input statement describes the arrangement of values in the input data record and assigns input values to the corresponding SAS variables.

EX. 
data work.kids;
infile 'kids.dat';
input name $ 1-8 siblings 10
@12 bdate mmddyy10.
@23 allowance comma2.
hobby1 $ hobby2 $ hobby3 $;
run;
86
Q
Which of the following is not an input style for the INPUT statement?
A. list input
B. column input
C. delimited input
D. formatted input
A

C. delimited input

87
Q

Column input

A

With column input, the column numbers that contain the value follow a variable in the INPUT statement.
To read with column input, data values:
must be in the same columns in all the input data records.
Must be in standard form.

Column input statement can contain:
variable- names a variable that is assigned input values.
$ : Indicates to store a variable value as a character value rather than as a numeric value.
start-column: Specifies the first column of the input record that contains the value to read.
-end-column: Specifies the last column of the input record that contains the value to read.

Ex. input name $ 1-8 siblings 10

88
Q

Formatted input

A

With formatted input, an informat follows a variable name and defines how SAS reads the value of this variable. An informat gives the data type and the field width of an input value.
To read with formatted input, data values
-Must be in the same columns inall the input data records.
Can be in standard or nonstandard form.

Formatted input statement can contain the following:
pointer-control-moves the input pointer to a specified column in the input buffer. @n moves the pointer to column n. +n moves the pointer n columns.
variable-names a variable that is assigned input values.
informat- specifies a SAS informat to use to read the variable values.

ex. input @12 bdate mmddyy10.
@23 allowance comma2.

89
Q

List input

A

With list input, variable names in the INPUT statement are specified in the same order that the fields appear in the input data records.
To read with list input data values:
-must be separated with a delimiter
-can be in standard or nonstandard form.

You must specify the variables in the order that they appear in the raw data file, left to right.
The default length for variables is 8 bytes.
A space (blank is the default delimiter.

pointer control: moves the input pointer to a specified column in the input buffer.
Variable: names a variable that is assigned input values.
$ : Indicates to store a variable value as a character value rather than as a numeric value.
: Reads data values that need additional instructions that informats can provide but are not aligned in columns.
informat: specifies an informat to use to read the variable values.

input hobby1 $
siblings
bdate : mmddyy10.
;

90
Q

input @45 name $10.

Which input technique is used in the above statement

A

Formatted input

91
Q
What third item is created at compile time in addition to the input buffer and the program data vector (PDV)?
A. report
B. data values
C. raw data file
D. descriptor information
A

D. descriptor information

92
Q

Data Errors

A

A data error is when the INPUT statement encounters invalid data in a field.
When SAS encounters a data error, these events occur:
A note that describes the error is printed in the SAS log.
The input record contents of the input buffer being read is displayed in the SAS log.
The values in the SAS observation (contents of the PDV) being created are displayed in the SAS log.
A missing value is assigned to the appropriate SAS variable.
Execution continues

93
Q

DATALINES statement

A

The DATALINES statement can be used with an INPUT statement to read data directly from the program, rather than data stored in a raw data file.
datalines;
Chloe 2 11/10/1995 $5Running Music Gymnastics
Travis 2 1/30/1998 $2Baseball Nintendo Reading
;
Run;

94
Q

Which statement is false concerning the DATALINES statement?
A. Multiple DATALINES statements can be used in a DATA step.
B. A null statement (a single semicolon) is needed to indicate the end of the input data.
C. The DATALINES statement is the last statement in the DATA step and immediately precedes the first data line.

A

A. Multiple DATALINES statements can be used in a DATA step.

95
Q

Standard Data

A

Standard data is any data that SAS can read without any special instructions.

96
Q
input name $ 1-8
siblings 10
bdate $ 12-21
allowance $ 23-24
hobby1 $ 26-35
hobby2 $ 36-45
hobby 3$ 46-55

How many variables are numeric and, ideally, how many variables should be numeric?

A

1 numeric variable and 3 variables should be numeric

97
Q

Nonstandard data

A

Nonstandard data is any data that SAS cannot read without a special instruction.

98
Q

Informat

A

An informat is an instruction that SAS uses to read data values into a variable
SAS uses the informat to determine the following:
-whether the variable is numeric or character
-the length of character variables.

99
Q

How will the following numbers be read with an informat of 8.2?

12345678 and 1234.567

A. 123456.78 and 1234.567
B. 123456.78 and 1234.56
C. 123456.7 and 1234.567
D. 123456.7 and 1234.56

A

A. 123456.78 and 1234.567

100
Q

Which statement is false regarding informats?
A. When you use an informat, the informat contains a period (.) as a part of the name.
B. The $ indicates a character informat, and the absence of a $ indicates a numeric informat.
C. An informat has a default width or specifies a width, which is the number of columns to read in the input data.
D. when a problem occurs with a valid informat, SAS writes a note to the SAS log, assigns a missing value to the variable, and terminates the DATA step.

A

D. when a problem occurs with a valid informat, SAS writes a note to the SAS log, assigns a missing value to the variable, and terminates the DATA step.

101
Q

DLM= option

A

The DLM= option specifies a delimiter to be used for list input. Blank is the default delimiter.
Ex.
infile ‘kids4.dat’ dlm=’ , ‘;

102
Q

Missing data (delimiter)

A

By default SAS treats two consecutive delimiters as one, not as a missing value between the delimiters.

103
Q

DSD option

A

The DSD option can do the following:
Treat two consecutive delimiters as a missing value
Remove quotation marks from strings and treat any delimiter inside the quotation marks as a valid character
Set the default delimiter to a comma.

infile ‘kids5.dat’ dsd;

104
Q

Missover option

A

The missover option prevents an INPUT statement from reading a new input data record if it does not find values in the current input line for all the variables in the statement. When an input statement reaches the end of the current input data record, variables without any values assigned are set to missing with the MISSOVER option.