1.
Which of the following statements associates the fileref OnSale with the raw data files London.dat, Paris.dat, and Zurich.dat? The files are stored in the C:\Routes\New directory in the Windows operating environment.
Correct Answer
C.
filename onsale ('c:\routes\new\london.dat'
'c:\routes\new\paris.dat'
'c:\routes\new\zurich.dat');
Explanation
When a FILENAME statement is used to assign a fileref to multiple raw data files, the list of files must be enclosed in a single set of parentheses. Each filename specified must be enclosed in quotation marks.
2.
Which of the following statements is true?
Correct Answer
D. All of the above
Explanation
The FILEVAR= option enables you to dynamically change the currently opened input file to a new input file. The FILEVAR= variable must contain a character string that is a physical filename. Like automatic variables, the FILEVAR= variable is not written to the data set.
3.
Given the following program, which table correctly shows the corresponding values of the variables x and readfile?
data work.revenue;
do x = 8, 9, 10;
readfile=compress("c:\data\month"
!!put(x,2.)!!".dat",' ');
do until (lastobs);
infile temp filevar=nextfile
end=lastobs;
input Date : date7. Location $
Sales : dollar10.2;
output;
end;
end;
stop;
run;
Correct Answer
B.
Explanation
The DO statement creates the index variable x and assigns it the values of 8, 9, and 10. The assignment statement assigns the name of a raw data file to readfile using the current value of x and the PUT function, which concatenates the values of x with the text strings c:\data\month and .dat. The COMPRESS function removes blank spaces from the values of readfile.
4.
If the current date is March 30, 2003, which table correctly shows the corresponding values of the variables y1, y2, y3, and nextfile?
data work.quarter (drop=monthnum midmon lastmon);
y3=year(today());
y2=y3-1;
y1=y3-2;
do i = y3, y2, y1;
nextfile="c:\data\Y"!!put(i,4.)!!".dat";
do until (lastobs);
infile temp filevar=nextfile
end=lastobs;
input Flight $ Origin $ Dest $
Date : date9.;
output;
end;
end;
stop;
run;
Correct Answer
A.
Explanation
The TODAY function returns the current date from the system clock as a SAS date value. The year number is then extracted from the current date using the YEAR function. The value of the current year, 2003, is assigned to y3. The year values 2002 and 2001 are assigned to y2 and y1, respectively. The PUT function concatenates the text string c:\data\Y with the year values and the text string .dat.
5.
Which of the following statements is false?
Correct Answer
A. The END= variable is set to 0 when SAS processes the last data record in the input file.
Explanation
The END= option enables you to name a variable whose value is controlled by SAS. The value of the variable is 0 when you are not reading the last record in an input file and 1 when you are reading the last record in an input file. You can test the value of the END= variable to determine if the DATA step should continue processing. Like automatic variables, the END= variable is not written to the SAS data set.
6.
Which program appends Work.London to Work.Flights?
Correct Answer
B.
proc append data=work.london
base=work.flights;
run;
Explanation
PROC APPEND uses the BASE= and DATA= arguments. BASE=SAS-data-set names the data set to which you want to add observations. DATA=SAS-data-set names the SAS data set containing observations that you want to append to the end of the SAS data set specified in the BASE= argument.
7.
What happens when the following program is submitted?
proc append base=staff.marketing
data=staff.sales force;
run;
Correct Answer
D. Some of the values of LastName may be truncated in the observations that are read in from Staff.Sales.
Explanation
If a DATA= data set contains variables that are longer than the corresponding variables in the BASE= data set, the FORCE option must be used with PROC APPEND. Using the FORCE option enables you to append the data sets. However, some of the variable values may be truncated in the observations that are read in from the DATA= data set.
8.
Which program appends Work.April to Work.Y2003?
Correct Answer
C.
proc append base=work.y2003
data=work.april force;
run;
Explanation
You must use the FORCE option with PROC APPEND when the DATA= data set contains a variable that does not have the same type as the corresponding variable in the BASE= data set.
9.
What happens when the SAS data set Work.NewHires is appended to the SAS data set Work.Employees using PROC APPEND?
Correct Answer
A. Missing values are assigned to Room for the observations that are read in from Work.NewHires.
Explanation
PROC APPEND reads only the data in the DATA= SAS data set, not the BASE= SAS data set. When the BASE= data set contains more variables than the DATA= data set, missing values for the additional variables are assigned to the observations that are read in from the DATA= data set.
10.
You do not need to use the FORCE option with PROC APPEND when
Correct Answer
B. The BASE= data set contains variables that are not in the DATA= data set.
Explanation
The FORCE option does not need to be used if the BASE= data set contains variables that are not in the DATA= data set. The FORCE option must be used if
the DATA= data set contains variables that are not in the BASE= data set
the variables in the DATA= data set are longer than the corresponding variables in the BASE= data set
the variables in the DATA= data set have a different type than the corresponding variables in the BASE= data set.