| Date: | Thu, 11 May 2000 16:23:42 -0400 |
| Reply-To: | john.zhang@QUINTILES.COM |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | john.zhang@QUINTILES.COM |
| Subject: | Q: assign value to a new variable depending on differences
between observation |
|
| Content-type: | text/plain; charset=us-ascii |
|---|
Dear SAS-L:
I have a dataset with 4 variables, the last variable bothtime is SAS datetime. I
need get a new variable, which values are depending on the differences between
bothtime variable. I need to give a new variable (interval)=1 for the first obs
in each patno, in this case obs 1, 9, 17, as they are these first obs in patno
301, 302, 303, then get differences between the first bothtime and each
individual bothtime for each observation, if the difference is <=24 hr,
interval=1, if 25-48 hrs, interval=3, if 49-72 interval=3.
OBS PATNO SAMPLE BOTHTIME
1 301 1 1238583300
2 301 2 1238627400
3 301 3 1238648580
4 301 4 1238674500
5 301 5 1238718600
6 301 6 1238755200
7 301 7 1238799300
8 301 8 1238842800
9 302 1 1239793200
10 302 2 1239837300
11 302 3 1239859200
12 302 4 1239879900
13 302 5 1239923220
14 302 6 1239966180
15 302 7 1240009200
16 302 8 1240052400
17 303 1 1240491900
18 303 2 1240534800
19 303 3 1240557300
20 303 4 1240578300
21 303 5 1240624200
22 303 6 1240664700
23 303 7 1240707600
24 303 8 1240751700
So the resulted dataset will be something like this:
OBS PATNO SAMPLE BOTHTIME Interval
1 301 1 1238583300
1
2 301 2 1238627400
1
3 301 3 1238648580
1
4 301 4 1238674500
2
5 301 5 1238718600
2
6 301 6 1238755200
3
7 301 7 1238799300
3
8 301 8 1238842800
3
9 302 1 1239793200
1
10 302 2 1239837300
1
11 302 3 1239859200
2
12 302 4 1239879900
2
13 302 5 1239923220
2
14 302 6 1239966180
3
15 302 7 1240009200
3
16 302 8 1240052400
8
17 303 1 1240491900
1
18 303 2 1240534800
1
19 303 3 1240557300
1
20 303 4 1240578300
1
21 303 5 1240624200
2
22 303 6 1240664700
3
23 303 7 1240707600
3
24 303 8 1240751700
3
Thanks in advance for your help.
John Zhang
|