SAS中文论坛

标题: HELP: Time issue using SAS code!! [打印本页]

作者: shiyiming    时间: 2011-3-8 03:39
标题: HELP: Time issue using SAS code!!
Hi everyone,

I have a question about time issue.

The original dataset has three columns:
ID, tsfd(time since first dose), dose(for ID=1, dosing twice,50 at time=0 and 100 at time=10).

Now I want to add another column called "tad"(time after last dose): when dosing(dose^=0), tad becomes 0, and calculate relative time interval!

I want output like this:

ID          tsfd                    dose         tad
1             0                        50              0
1             1                         0               1
1             5                         0               5
1             8                         0               8
[color=#4000FF:2uyxugnk]1            10                   100               0
1            12                      0               2
1            15                      0               5[/color:2uyxugnk]
2
2
....

How can I use SAS code to add the column "tad"??

Thanks!!!
作者: shiyiming    时间: 2011-3-8 20:45
标题: Re: HELP: Time issue using SAS code!!
希望这个是楼主要的
[code:2vdbymz1]
data have;
        input ID $ tsfd dose;
datalines;
1 0 50
1 1 0
1 5 0
1 8 0
1 10 100
1 12 0
1 15 0
;
run;
data want(drop=temp);
        set have;
        retain temp;
        if dose ne 0 then temp=tsfd;
        tad=tsfd-temp;
run;
[/code:2vdbymz1]




欢迎光临 SAS中文论坛 (http://mysas.net/forum/) Powered by Discuz! X3.2