Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP: Complex time issue SAS code!!!

Status
Not open for further replies.

zxlsupergirl48

Programmer
Mar 6, 2011
7
US
Hi everyone,

I have a question about time issue.

The original dataset has three column:
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)

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
1 10 100 0
1 12 0 2
1 15 0 5
2
2
....

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

Thanks!!!
 
Because this is multiple dosing(for example, ID=1, dosing 50 when tsfd=0 and dosing 100 when tsfd=10), I want to create a new variable to calculte relative time (consider every dosing time as baseline), so when tsfd=0 and tsfd=10, tad=0

So we have tad:
0 (dosing)
1
5
8
0 (dosing twice)
2
5


After getting this new variable, I could use it to perform future plots and analysis.

Thanks!!
 
Can anybody help me to solve this problem? Or give me any hint!?

I really appreciate it!:)
 
I'd love to help, but I cannot get my head around how tad would be worked out... if you can give me a written example of what you'd expect tad to be and why...
 
Thanks!!

I have already figured it out!

Will share the code with everybody^^

data b;
set a;
by id ;
retain bltime;
if first.id then bltime=0;
if amt^=0 then bltime=tsfd;
tad=tsfd-bltime;
run;

ID tsfd dose bltime tad
1 0 50 0 0
1 1 0 0 1
1 5 0 0 5
1 8 0 0 8
1 10 100 10 0
1 12 0 10 2
1 15 0 10 5
2 0 50 0 0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top