由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - SAS code求助
相关主题
SAS问题求助Help! A data step problem
问个问题stepwise regression in SAShow to group according to the value of a variable?
问一个SAS DATA 处理的问题,谢谢!一个简单spss问题,不知道有没有解决办法?
请教sas adv 130题中 第12题 第19题[合集] use SAS to generate descriptive statistics for variable
question about generating new variables in stata or SAS请教一个proc transpose的问题
Use SAS to fill in missing values?How to dynamically display title for a graph in R?
SAS help needed, interpolating missing values这个sas code该如何写?
请教一个很白痴的回归分析的问题sas base (70) problem 59 help
相关话题的讨论汇总
话题: missing话题: flag话题: value话题: values话题: following
进入Statistics版参与讨论
1 (共1页)
l*******1
发帖数: 6
1
The data has so many continuous missing values.
Based on Time variable and value variable, how to generate flag variable
according to the following criteria?
For no missing values, flag=0;
first missing value flag=-1
middle missing value flag=1
last missing value flag=2
Time value flag
1 56 0
2 34 0
3 26 0
4 19 0
5 70 0
6 66 0
7 . -1
8 . 1
9 . 1
10 . 2
11 35 0
12 23 0
13 90 0
14 82 0
15 44 0
16 . -1
17 . 1
18 . 1
19 . 1
20 . 1
21 . 2
22 34 0
23 45 0
24 65 0
25 50 0
26 100 0
27 39 0
28 .-1
29 . 1
30 . 1
31 . 1
32 . 1
33 . 1
34 . 2
35 67 0
36 78 0
Great Thanks
k*******a
发帖数: 772
2
假设你的data是a
data b;
set a;
if value=. then flag=1;
else flag=0;
run;
data c;
set b;
by flag notsorted;
if flag=1 then do;
if first.flag then flag=-1;
else if last.flag then flag=2;
end;
run;
这里的问题就是,如果连续missing只有1个的话,这个程序给的是2,如果希望其他数
值,可以相应调整
l*******1
发帖数: 6
3

Actually for 1 missing, I need to replace it with its previous value and
following value, For continuous 2 missing, i will replace them with previous
2 and following 2 values, for continuous 3 missing, i will replace them
with previous 3 and following 3 values.(If these missing are not in the end)
,so for the remaining data, It will have at least 4 missing values.
Would you add these code before that you provide to get rid of <=3 missing?
Thank you very much.

【在 k*******a 的大作中提到】
: 假设你的data是a
: data b;
: set a;
: if value=. then flag=1;
: else flag=0;
: run;
: data c;
: set b;
: by flag notsorted;
: if flag=1 then do;

1 (共1页)
进入Statistics版参与讨论
相关主题
sas base (70) problem 59 helpquestion about generating new variables in stata or SAS
time-dependent variableUse SAS to fill in missing values?
How to deal with the NULL value?SAS help needed, interpolating missing values
data grouping, sub-grouping by column variable in R请教一个很白痴的回归分析的问题
SAS问题求助Help! A data step problem
问个问题stepwise regression in SAShow to group according to the value of a variable?
问一个SAS DATA 处理的问题,谢谢!一个简单spss问题,不知道有没有解决办法?
请教sas adv 130题中 第12题 第19题[合集] use SAS to generate descriptive statistics for variable
相关话题的讨论汇总
话题: missing话题: flag话题: value话题: values话题: following