由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - sas code
相关主题
请教一个proc transpose的问题这个DATA如何做TRNASPOSE?
怎样用R定位变量的位置问个SAS数据处理的问题
How to sort the columns in SAS?请教一个transpose的问题,在线等
问2个sql left join的问题求高人指点一个SAS数据的转换问题
一个看着很简单sas的问题SAS DATA PROCESSING 问题
[R] a row of a matrix is not a matrix?双包子求教:sas data manipulation问题
如何把取值为1的column列出来?包子问,SAS里data long to wide format
how to trasform data.请教大家一个SAS combine data set 的问题
相关话题的讨论汇总
话题: day话题: status话题: end话题: pre话题: data
进入Statistics版参与讨论
1 (共1页)
a********a
发帖数: 346
1
I want the following data set tranfer into another data set.
Id pre_status end_status day
1 0 1 0
1 1 2 210
1 2 4 252
I.e. the pre_status 0 in not included, and the day is transposed into two
columns.
I want the data transfer like the following:
Id pre_status end_status start_day, end_day
1 1 2 0 210
1 2
A*******s
发帖数: 3942
2
how do you get the value of start_day?

【在 a********a 的大作中提到】
: I want the following data set tranfer into another data set.
: Id pre_status end_status day
: 1 0 1 0
: 1 1 2 210
: 1 2 4 252
: I.e. the pre_status 0 in not included, and the day is transposed into two
: columns.
: I want the data transfer like the following:
: Id pre_status end_status start_day, end_day
: 1 1 2 0 210

a********a
发帖数: 346
3
start_day from the variable day, first start_day is from the first
observation, day=0, end_day is the second row. Then this end_day will be a
start_day in second row. Is this clear? Thanks
A*******s
发帖数: 3942
4
data new;
set old;
retain lag_day;
start_day=lag_day;
end_day=day;
lag_day=day;
if pre_status ne 0;
drop day lag_day;
run;

【在 a********a 的大作中提到】
: start_day from the variable day, first start_day is from the first
: observation, day=0, end_day is the second row. Then this end_day will be a
: start_day in second row. Is this clear? Thanks

a********a
发帖数: 346
5
Thanks actuaries. Excellent data programming technique.
d*******o
发帖数: 493
6
data one;
input Id pre_status end_status end_day;
start_day=lag(end_day);
if end_day ne 0 then output;
cards;
1 0 1 0
1 1 2 210
1 2 4 252
;
w*******n
发帖数: 469
7
I like this one more.

【在 d*******o 的大作中提到】
: data one;
: input Id pre_status end_status end_day;
: start_day=lag(end_day);
: if end_day ne 0 then output;
: cards;
: 1 0 1 0
: 1 1 2 210
: 1 2 4 252
: ;

S******y
发帖数: 1123
8
# It can be done in Python too. Furthermore, we also check data -
# if first record of a new id has non-zero pre_status code, raise error
# if start date > end date, raise error
in_file = 'D:\\startdt.txt'
f = open(in_file, 'r')
prev_day = None
prev_id = None
print 'Id, pre_status, end_status, start_day, end_day'
for line in f:
idx, pre_status, end_status, day = line.split()
if pre_status == '0':
pass
else:
if (prev_id == None) or (prev_id != None and prev_id != idx):
1 (共1页)
进入Statistics版参与讨论
相关主题
请教大家一个SAS combine data set 的问题一个看着很简单sas的问题
sas大牛们这个要怎么实现呀[R] a row of a matrix is not a matrix?
一个SAS初级问题。。。菜鸟求教如何把取值为1的column列出来?
求救:关于Excel作图--cluster bar charthow to trasform data.
请教一个proc transpose的问题这个DATA如何做TRNASPOSE?
怎样用R定位变量的位置问个SAS数据处理的问题
How to sort the columns in SAS?请教一个transpose的问题,在线等
问2个sql left join的问题求高人指点一个SAS数据的转换问题
相关话题的讨论汇总
话题: day话题: status话题: end话题: pre话题: data