标题: 紧急求助!!明天考SAS BASE!! [打印本页] 作者: shiyiming 时间: 2008-2-26 10:33 标题: 紧急求助!!明天考SAS BASE!! 1. A frequency report of the variable JOBCODE in the WORK.ACTORS data set is listed below:
The FREQ Procedure
Jobcode Frequency Percent Cumulative Cumulative
Frequency Percent
Actor I 2 33.33 2 33.33
Actor II 2 33.33 4 66.67
Actor III 2 33.33 6 100.00
Frequency Missing = 1
The following SAS program is submitted:
data work.joblevels;
set work.actors;
if jobcode in ('Actor I', 'Actor II') then
joblevel = 'Beginner';
if jobcode = 'Actor III' then
joblevel = 'Advanced';
else
joblevel = 'Unknown';
run;
Which of the following represents the possible values for the variable JOBLEVEL in the
WORK.JOBLEVELS data set?
A. Advanced and Unknown only
B. Beginner and Advanced only
C. Beginner, Advanced, and Unknown
D. ' ' (missing character value)
答案是a.
The data step will continue to process those observations that satisfy the condition in the first IF statement Although JOBLEVEL might be set to BEGINNER for one or more observations, the condition on the second IF statement will evaluate as false and the ELSE statement will execute and overwrite the value of JOBLEVEL as UNKONWN.
My question is I don’t understand why EISE statement will execute and overwrite the value of JOBLEVEL as UNKNOW.
When SAS read the raw data, the first to be read is ACTOR I, then if jobcode in ACTOR I then JOBLEVEL is Beginner. Then the second IF statement will execute and since the JOBCODE is ACTOR I, the second IF statement evaluated as false. The ELSE statement will execute, and since the JOBCODE is ACTOR I, the ELSE statement evaluated as false. So I don’t understand why there are just two values for the variable JOBLEVEL and why there is no BEGINNER.
2. The following SAS program is submitted:
Data work.empsalary;
Set work.people (in=inemp)
Work.money (in=insal);
If insal and inemp;
Run;
The SAS data set WORK.PEOPLE has 5 observations, and the data set WORK.MONEY has 7 observations.
How many observations will the data set WORK.EMPSALARY contain
a.0
b.5
c.7
d.12
ANSWER: a
I don’t know why the correct answer is a. From the program, we know that we plan to concatenate the two data sets. My answer is D. But when I run the program, the message in the Log Window is there is 0 observation in the data set WORK.EMPSALARY.
3. The contents of the SAS data set named PERM.STUDENTS are listed below:
name age
Alfred 14
Alice 13
Barbara 13
Carol 14
The following SAS program is submitted using the PERM.STUDENTS data set as input:
libname perm 'SAS-data-library';
data students;
set perm.students;
file 'file-specification';
put name $15. @5 age 2.;
run;
Which one of the following represents the values written to the output raw data file?
A. --------10-------20-------30
Alfred 14
Alice 13
Barbara 13
Carol 14
B. --------10-------20-------30
Alfr14
Alic13
Barb13a
Caro14
C. --------10-------20-------30
Alfr14ed
Alic13e
Barb13ara
Caro14l
D. --------10-------20-------30
Alfred 14
Alice 13
Barbara 13
Carol 14
ANSWER B. I don’t know why there is a “a” behind 13.
The following two question are both about concatenation operator. 4. answer is A. some people told me because the length of JobCategory already set to 2 by the first assignment statement(JobCategory=’FA’). But if like this, the length of City_Country has been set to 16 because of the first assignment statement. But the correct answer is D. I still have a question, when I read the book I know that the length of the newvariable is the sum of the lengths of each variable. But if like this, for 4 then correct answer is B. I am totally puzzled.
4. The following SAS program is submitted:
data work.staff;
JobCategory = 'FA';
JobLevel = '1';
JobCategory = JobCategory JobLevel;
run;
Which one of the following is the value of the variable JOBCATEGORY in the output data set?
A. FA
B. FA1
C. FA 1
D. ' ' (missing character value)
Click Comment link to get answer
5. The following SAS program is submitted:
data work.test;
First = 'Ipswich, England';
City = substr(First,1,7);
City_Country = City!!', '!!'England';
run;
Which one of the following is the value of the variable CITY_COUNTRY in the output data set?
A. Ipswich!!
B. Ipswich, England
C. Ipswich, 'England'
D. Ipswich , England
6.The following SAS program is submitted:
data work.products;
Product_Number = 5461;
Item = '1001';
Item_Reference = Item'/'Product_Number;
run;
Which one of the following is the value of the variable ITEM_REFERENCE in the output data set?
A. 1001/5461
B. 1001/ 5461
C. . (missing numeric value)
D. The value can not be determined as the program fails to execute due to errors.
7.The following SAS program is submitted:
data work.test;
First = 'Ipswich, England';
City_Country = substr(First,1,7)!!', '!!'England';
run;
Which one of the following is the length of the variable CITY_COUNTRY in the output data set?
A. 6
B. 7
C. 17
D. 25
8.The following SAS program is submitted:
data work.test;
Title = 'A Tale of Two Cities, Charles J. Dickens';
Word = scan(title,3,' ,');
run;
Which one of the following is the value of the variable WORD in the output data set?
A. T
B. of
C. Dickens
D. ' ' (missing character value)作者: shiyiming 时间: 2008-2-26 10:34 标题: Re: 紧急求助!!明天考SAS BASE!! 大家都来帮帮忙吧! 小妹谢谢大家了作者: shiyiming 时间: 2008-3-1 14:34 标题: Re: 紧急求助!!明天考SAS BASE!! 在sas上运行就知道结果了