s********1 发帖数: 54 | 1 I wrote the following code in sas:
data students;
input gender score;
cards;
1
1 45
2 50
2 42
1 41
2 51
1 52
1 43
2 52
. 12
. 13
;
run;
I do not know why the output in SAS shows as follows:
Obs gender score
1 1 1
2 2 50
3 2 42
4 1 41
5 2 51
6 1 52
7 1 43
8 2 52
9 . 12
10 . 13
Who can explain to me? Thank you so much!!!! | d******9 发帖数: 404 | 2 Hehe..... you need use Missover.
Try below codes:
data students;
infile cards missover;
input gender score;
cards;
1
1 45
2 50
2 42
1 41
2 51
1 52
1 43
2 52
. 12
. 13
;
run; | k*******a 发帖数: 772 | | k*****u 发帖数: 1688 | 4 二楼正解。
没有missover的话,sas会到下一行去读取数据。 | s********1 发帖数: 54 | 5 Thank you so much.
(1)But can you tell me why SAS stops reading 45 and goes to read 2 and 50
for obs2? In my opinion, I thought it should be
obs1:(1,1) and obs2:(45,2) and obs3:(50,2),etc.
(2)If my data set should look like obs1:(1,1) and obs2:(45,2) and obs3:(50,2
),etc, how should write the code.
Thanks again.
I wrote the following code in sas:
data students;
input gender score;
cards;
1
1 45
2 50
2 42
1 41
2 51
1 52
1 43
2 52
. 12
. 13
;
run;
I do not know why the output in SAS shows as follows:
Obs gender score
1 1 1
2 2 50
3 2 42
4 1 41
5 2 51
6 1 52
7 1 43
8 2 52
9 . 12
10 . 13
Who can explain to me? Thank you so much!!!!
【在 d******9 的大作中提到】![](/moin_static193/solenoid/img/up.png) : Hehe..... you need use Missover. : Try below codes: : data students; : infile cards missover; : input gender score; : cards; : 1 : 1 45 : 2 50 : 2 42
| d******9 发帖数: 404 | 6 By default, if SAS can not find values for all the variables defined in
INPUT statement, it will automatically go to NEXT record to read the values
until it get all the values for all the vars.
This is called FLOWOVER, which is the default mode in SAS data step.But, as
you have seen, it may make trouble and destroy the data totally. So,
sometimes we have to disable it.
In this case, we may use Missover/TruncOver/StopOver options in INFILE
statement depending on situations.
For details, view SAS Support by google: Missover. | s********1 发帖数: 54 | 7 Thank you!!
values
as
【在 d******9 的大作中提到】![](/moin_static193/solenoid/img/up.png) : By default, if SAS can not find values for all the variables defined in : INPUT statement, it will automatically go to NEXT record to read the values : until it get all the values for all the vars. : This is called FLOWOVER, which is the default mode in SAS data step.But, as : you have seen, it may make trouble and destroy the data totally. So, : sometimes we have to disable it. : In this case, we may use Missover/TruncOver/StopOver options in INFILE : statement depending on situations. : For details, view SAS Support by google: Missover.
|
|