1.A raw data file is listed below.
1---+----10---+----20---+--- son Frank 01/31/89
daughter June 12-25-87 brother Samuel 01/17/51
The following program is submitted using this file as input:
data work.family;
infile 'file-specification';
Which INPUT statement correctly reads the values for the variable Birthdate as SAS date values? a. input relation $ first_name $ birthdate date9.; input relation $ first_name $ birthdate mmddyy8.; b.
input relation $ first_name $ birthdate : date9.; c.
input relation $ first_name $ birthdate : mmddyy8.; d.
Correct answer: d
An informat is used to translate the calendar date to a SAS date value. The date values are in the form of two-digit values for month-day-year, so the MMDDYY8. informat must be used. When using an informat with list input, the colon-format modifier is required to correctly associate the informat with the variable name. You can learn about
? ?
informats in Reading Date and Time Values
the colon-format modifier in Reading Free-Format Data.
2.A raw data file is listed below.
1---+----10---+----20---+--- Jose,47,210 Sue,,108
The following SAS program is submitted using the raw data file above as input:
data employeestats;
The following output is desired:
name age weight Jose 47 210 Sue . 108
Which of the following INFILE statements completes the program and accesses the data correctly?
a. infile 'file-specification' pad; b. infile 'file-specification' dsd;
SAS中文论坛网站http://www.mysas.net SAS中文论坛FTP站ftp://mysas.vicp.net
c. infile 'file-specification' dlm=','; d. infile 'file-specification' missover;
Correct answer: b
The PAD option specifies that SAS pad variable length records with blanks. The
MISSOVER option prevents SAS from reading past the end of the line when reading free formatted data. The DLM= option specifies the comma as the delimiter; however,
consecutive delimiters are treated as one by default. The DSD option correctly reads the data with commas as delimiters and two consecutive commas indicating a missing value like those in this raw data file. You can learn about
the PAD option in Reading Raw Data in Fixed Fields
the MISSOVER option in Creating Multiple Observations from a Single Record
? the DLM= option and the DSD option in Reading Free-Format Data.
? ?
3.The following program is submitted:
data numrecords;
infile cards dlm=',';
input agent1 $ agent2 $ agent3 $; cards;
jones,,brownjones,spencer,brown ; run;
What is the value for the variable named Agent2 in the second observation?
a. b. c. d. brown spencer
' ' (missing character value)
There is no value because only one observation is created.
Correct answer: d
The CARDS statement enables you to read instream data. Any number of consecutive commas are considered to be a single delimiter as a result of the DLM= option, and the length of each variable defaults to 8 bytes. Therefore, the values jones, brownjon, and spencer are assigned to Agent1, Agent2, and Agent3, respectively, for the first
observation. The rest of the data on the record is not read by the INPUT statement and is not output to the data set. You can learn about
? ?
the CARDS statement in Creating SAS Data Sets from Raw Data the default length of variables in Reading Free-Format Data.
SAS中文论坛网站http://www.mysas.net SAS中文论坛FTP站ftp://mysas.vicp.net
4.A raw data file is listed below.
1---+----10---+----20---+----30---+----40---+----50 TWOSTORY 1040 2 1SANDERS ROAD $55,850 CONDO 2150 4 2.5JEANS AVENUE $127,150
The following program is submitted using this file as input:
data work.houses;
infile 'file-specification';
Which one of the following INPUT statements reads the raw data file correctly? a. input @1 style $8.
+1 sqfeet 4. +1 bedrooms 1. @20 baths 3. street 16.
@40 price dollar8;
input @1 style $8 b.
+1 sqfeet 4. +1 bedrooms 1. @20 baths 3. street $16
@40 price dollar8.;
input @1 style $8. c.
+1 sqfeet 4. +1 bedrooms 1. @20 baths 3. street $16.
@40 price dollar8.;
input @1 style $8. d.
+1 sqfeet 4. +1 bedrooms 1. @20 baths 3 street 16.
@40 price dollar8.;
Correct answer: c
Formatted input requires periods as part of the informat name. The period is missing from the variables Style and Street in Answer b, the variable Baths in Answer d, and the variable Price in Answer a (which is also missing a dollar sign to read the variable Street as a character value).
You can learn about formatted input and informats in Reading Raw Data in Fixed Fields.
5. The following SAS program is submitted at the start of a new SAS session:
libname sasdata 'SAS-data-library'; data sasdata.sales;
set sasdata.salesdata; profit=expenses-revenues; run;
SAS中文论坛网站http://www.mysas.net SAS中文论坛FTP站ftp://mysas.vicp.net
proc print data=sales; run;
The SAS data set Sasdata.Salesdata has ten observations. Which one of the following explains why a report fails to generate? a. The DATA step fails execution.
b. The SAS data set Sales does not exist.
c. The SAS data set Sales has no observations. d. The PRINT procedure contains a syntax error. Correct answer: b
The DATA step creates a permanent SAS data set, Sasdata.Salesdata. The PRINT
procedure is printing a temporary SAS data set, Sales, that is stored in the Work library. At the beginning of the SAS session, Work.Sales does not exist. You can learn about
creating permanent data sets with the DATA step in Creating SAS Data Sets from Raw Data
? temporary data sets in Basic Concepts.
?
6. Which action assigns a reference named SALES to a permanent SAS data library? a. Issuing the command:
libref SALES 'SAS-data-library'
b. Issuing the command:
libname SALES 'SAS-data-library'
c. d.
Submitting the statement: Submitting the statement:
libref SALES 'SAS-data-library'; libname SALES 'SAS-data-library';
Correct answer: d
The LIBNAME statement assigns a reference known as a libref to a permanent SAS data library. The LIBNAME command opens the LIBNAME window.
You can learn about the LIBNAME statement in Referencing Files and Setting Options. 7. The following SAS program is submitted:
data newstaff; set staff;
Which one of the following WHERE statements completes the program and selects only observations with a Hire_date of February 23, 2000? a. where hire_date='23feb2000'd; b. where hire_date='23feb2000'; c. where hire_date='02/23/2000'd;
SAS中文论坛网站http://www.mysas.net SAS中文论坛FTP站ftp://mysas.vicp.net
d. where hire_date='02/23/2000';
Correct answer: a
A SAS date constant must take the form of one- or two-digit day, three-digit month, and two- or four-digit year, enclosed in quotation marks and followed by a d ('ddmmmyy
You can learn about SAS date constants in Creating SAS Data Sets from Raw Data.
8. Which one of the following SAS date formats displays the SAS date value for January 16, 2002 in the form of 16/01/2002? a. DATE10. b. DDMMYY10. c. WEEKDATE10. d. DDMMYYYY10. Correct answer: b
The requested output is in day-month-year order and is 10 bytes long, so DDMMYY10. is the correct format. Although WEEKDATE10. is a valid SAS format, it does not display the SAS date value as shown in the question above. DDMMYYYY10. is not a valid SAS date format, and the DATEw. format cannot accept a length of 10. You can learn about
? ?
the DDMMYY10. format in Creating List Reports
the WEEKDATE10. format in Reading Date and Time Values.
9. Which one of the following displays the contents of an external file from within a SAS session? a. the LIST procedure b. the PRINT procedure c. the FSLIST procedure d. the VIEWTABLE window Correct answer: c
The PRINT procedure and VIEWTABLE window display the values in SAS data sets. The FSLIST procedure displays the values in external files. There is no LIST procedure in SAS.
You can learn about
?
the PRINT procedure in Creating List Reports
SAS中文论坛网站http://www.mysas.net SAS中文论坛FTP站ftp://mysas.vicp.net