由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - ##问一个SAS BASE 问题##
相关主题
再问道SAS的题目HELP~~About reading sas data set
急了,问道SAS题,(下午考)help! SAS base 70 problem 17/35
[合集] SAS里如何实现LOCF(LAST OBS CARRIED FORWARD)?a SAS question in base 70
do loop 的一道题[合集] 请教一个SAS数据input的问题
请教一个SAS数据input的问题SAS question (紧急求助,在线等)
[SAS] data set options (obs=) in output tables请教一个SAS问题
请教 sas base 70题 第46题SAS help needed!
请帮忙解答两个SAS base考题syntax errors
相关话题的讨论汇总
话题: age话题: data话题: tineke话题: june话题: john
进入Statistics版参与讨论
1 (共1页)
t*****2
发帖数: 94
1
QUESTION
A raw data file is listed below:
---|---10---|---20---|----30
John McCloskey 35 71
June Rosesette 10 43
Tineke Jones 9 37
The following SAS program is submitted using the raw data file as input:
data work.homework;
infile 'file-specification';
input name $ age height;
if age LE 10;
run;
How many observations will the WORK.HOMEWORK data set contain?
A. 0 B. 2 C. 3
为什么答案是3个呢?我觉得读数据的时候就应该会出现ERROR呀, 即便不出现问题,
也只可能是2个呀。
求赐教! 先谢谢了!
m*********n
发帖数: 413
2
the definition and the input of a variable are two different stories. In
this case there is no code error, and thus the data step was running. The
three variables therefore have been defined although you cannot read in
valid data.
t*****2
发帖数: 94
3
但是这里问的是有多少个OBSERVATIONS,不是VARIABLES.
variable是有3个,但是observation用LE 10就可以剔除一个呀。
请指教!
l***i
发帖数: 8
4
答案肯定是3个observations,因为后面的if语句对挑选几个observations不起作用。
h********o
发帖数: 103
5
This is LIST INPUT in which its default delimiter is blank. The data for AGE
variable are invalid since you define variable as numeric but you require
inputting charater values. So all three AGE values are set to missing and of
course less than or equal to 10.
t*****2
发帖数: 94
6
Thanks very much!
l***i
发帖数: 8
7
原来是这么个原因。我开始理解成,数据没读对,所以if没起作用呢。谢谢honglajiao
的解释!
f******x
发帖数: 14
8
Nobody try? I tried, it gives me 2 obs.
S******3
发帖数: 66
9
The key (考点)is: SAS will go to a new line when INPUT statement reached
past the end of a line without finding the specified delimiter. Here it
reads row 1 and row 2 as one record, so 3 is right.
h********o
发帖数: 103
10
See output:
==============================
data test;
input name $ age height;
if age LE 10;
cards;
John McCloskey 35 71
June Rosesette 10 43
Tineke Jones 9 37
;
proc print data = test;
run;
==============================
Obs name age height
1 John . 35
2 June . 10
3 Tineke . 9
相关主题
[SAS] data set options (obs=) in output tablesHELP~~About reading sas data set
请教 sas base 70题 第46题help! SAS base 70 problem 17/35
请帮忙解答两个SAS base考题a SAS question in base 70
进入Statistics版参与讨论
S******3
发帖数: 66
11
Ooops, I thought the 1st row of raw text file is "---|---10---|---20---|----
30"

【在 S******3 的大作中提到】
: The key (考点)is: SAS will go to a new line when INPUT statement reached
: past the end of a line without finding the specified delimiter. Here it
: reads row 1 and row 2 as one record, so 3 is right.

c*****l
发帖数: 297
12
如果把IF 改成WHERE 就是0 了

【在 t*****2 的大作中提到】
: QUESTION
: A raw data file is listed below:
: ---|---10---|---20---|----30
: John McCloskey 35 71
: June Rosesette 10 43
: Tineke Jones 9 37
: The following SAS program is submitted using the raw data file as input:
: data work.homework;
: infile 'file-specification';
: input name $ age height;

h********o
发帖数: 103
13
You must use IF statement when accessing raw data file using INPUT statement
. You can't use WHERE statement in this case otherwise SAS will generate
ERROR message.
a*****9
发帖数: 1315
14
I tried , gives me 3 obs
data a
input name $ age height;
if age LE 10;
datalines;
John McCloskey 35 71
June Rosesette 10 43
Tineke Jones 9 37
;
proc print data=test;
run;
but couldn't figure out why ?

【在 f******x 的大作中提到】
: Nobody try? I tried, it gives me 2 obs.
f******x
发帖数: 14
15
From your code, it will give you information:
OTE: Invalid data for age in line 5 6-14.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+
----7----+----8----+----9----+----0
5 John McCloskey 35 71
name=John age=. height=35 _ERROR_=1 _N_=1
NOTE: Invalid data for age in line 6 6-14.
6 June Rosesette 10 43
name=June age=. height=10 _ERROR_=1 _N_=2
NOTE: Invalid data for age in line 7 8-12.
7 Tineke Jones 9 37
name=Tineke age=. height=9 _ERROR_=1 _N_=3
Modify you code as:
data b;
input name $ 1-15 age height;
if age LE 10;
datalines;
John McCloskey 35 71
June Rosesette 10 43
Tineke Jones 9 37
;
proc print data=b; run;
Here is the result:
Obs name age
height
1 June Rosesette 10
43
2 Tineke Jones 9
37

【在 a*****9 的大作中提到】
: I tried , gives me 3 obs
: data a
: input name $ age height;
: if age LE 10;
: datalines;
: John McCloskey 35 71
: June Rosesette 10 43
: Tineke Jones 9 37
: ;
: proc print data=test;

1 (共1页)
进入Statistics版参与讨论
相关主题
syntax errors请教一个SAS数据input的问题
sas base 70 key -errors[SAS] data set options (obs=) in output tables
about Q70 of sas base请教 sas base 70题 第46题
Base 70 第35题怎么理解? 谢谢。请帮忙解答两个SAS base考题
再问道SAS的题目HELP~~About reading sas data set
急了,问道SAS题,(下午考)help! SAS base 70 problem 17/35
[合集] SAS里如何实现LOCF(LAST OBS CARRIED FORWARD)?a SAS question in base 70
do loop 的一道题[合集] 请教一个SAS数据input的问题
相关话题的讨论汇总
话题: age话题: data话题: tineke话题: june话题: john