From: Ya on 9 Aug 2010 14:28 On Aug 9, 11:17 am, William <shawfee....(a)gmail.com> wrote: > On Aug 10, 12:23 am, Ya <huang8...(a)gmail.com> wrote: > > > > > > > On Aug 8, 10:06 pm, William <shawfee....(a)gmail.com> wrote: > > > > On Aug 9, 12:51 pm, Barry Schwarz <schwa...(a)dqel.com> wrote: > > > > > Sort by type, date, and time. > > > > > Loop through observations. > > > > When you reach one with an index of interest, compute the end > > > > time of interest and retain the index value and end time. Also set a > > > > flag indicating that index should be updated. > > > > If the update flag is set, check the time against end time. When > > > > less, update index. When not, reset the update flag. > > > > > On Sun, 8 Aug 2010 21:07:04 -0700 (PDT), William > > > > > <shawfee....(a)gmail.com> wrote: > > > > >data example: > > > > >obs type date id time number index > > > > >1 B11 20030303 1301 900 1 > > > > >2 B12 20030303 1301 900 2 > > > > >3 B12 20030303 1301 902 1 > > > > >4 B12 20030303 1301 904 1 > > > > >5 B11 20030303 1301 905 1 > > > > >6 B12 20030303 1301 905 2 > > > > >7 B12 20030303 1301 910 3 > > > > >8 B12 20030303 1301 910 5 > > > > >9 B12 20030303 1301 911 1 > > > > >10 B12 20030303 1301 913 1 > > > > >11 B11 20030303 1301 913 3 1 > > > > >12 B12 20030303 1301 913 4 > > > > >13 B12 20030303 1301 914 1 > > > > >14 B11 20030303 1301 915 1 > > > > >15 B12 20030303 1301 915 2 > > > > >16 B12 20030303 1301 917 1 > > > > >17 B12 20030303 1301 918 1 > > > > >18 B12 20030303 1301 931 2 > > > > >19 B12 20030303 1301 932 1 > > > > >20 B11 20030303 1301 933 5 > > > > >21 B12 20030303 1301 933 6 > > > > >22 B12 20030303 1301 934 1 > > > > >23 B12 20030303 1301 934 3 > > > > >24 B11 20030303 1301 934 5 2 > > > > >25 B12 20030303 1301 934 6 > > > > >26 B12 20030303 1301 935 1 > > > > >27 B12 20030303 1301 936 1 > > > > >28 B11 20030303 1301 937 1 > > > > >29 B12 20030303 1301 937 2 > > > > >30 B12 20030303 1301 937 4 > > > > >31 B11 20030303 1301 939 1 > > > > >32 B12 20030303 1301 939 2 > > > > >33 B12 20030303 1301 955 1 > > > > >34 B11 20030303 1301 956 1 > > > > >35 B12 20030303 1301 956 2 > > > > >36 B11 20030303 1301 957 1 > > > > >37 B12 20030303 1301 957 2 > > > > >38 B12 20030303 1301 957 4 > > > > >39 B11 20030303 1301 958 1 3 > > > > >40 B12 20030303 1301 958 2 > > > > >41 B11 20030303 1301 959 1 > > > > > >when type=B11 and index=1, time is 9:13, I want to get the following > > > > >five minutes observation and type=B12, > > > > > >for example, > > > > >when type=B11 and index=1, time is 9:13, I want to get the following > > > > >five minutes observation, that is to say get the observation from 12, > > > > >13, 15, 16, 17 and have a varable flag equal index=1. > > > > > >when type=B11 and index=2, time is 9:34, I want to get the following > > > > >five minutes observation, that is to say get the observation from 25, > > > > >26, 27, 29, 30, 32 and have a varable flag equal index=2. etc.. > > > > > >My data have millions of observation, different id, different date, > > > > >different time, different number, and the index has more 20,000. How > > > > >to solve this question? > > > > > >Thank you so much! > > > > >-Xiaofei > > > > > -- > > > > Remove del for email > > > > proc sort data=a; by type date time; run; > > > > Then I do not know what to do, I do not understand it clearly. Can you > > > write down the program? Thanks. > > > -Xiaofei- Hide quoted text - > > > > - Show quoted text - > > > data need; > > set example; > > retain flag0; > > if ^missing(index) then do; > > n_=0; flag0=index; end; > > if type='B12' then n_+1; > > if n_<=5 and type='B12' then flag=flag0; > > drop flag0 n_; > > run; > > > proc print; > > run; > > > obs type date id time number index flag > > > 1 B11 20030303 1301 900 1 . . > > 2 B12 20030303 1301 900 2 . . > > 3 B12 20030303 1301 902 1 . . > > 4 B12 20030303 1301 904 1 . . > > 5 B11 20030303 1301 905 1 . . > > 6 B12 20030303 1301 905 2 . . > > 7 B12 20030303 1301 910 3 . . > > 8 B12 20030303 1301 910 5 . . > > 9 B12 20030303 1301 911 1 . . > > 10 B12 20030303 1301 913 1 . . > > 11 B11 20030303 1301 913 3 1 . > > 12 B12 20030303 1301 913 4 . 1 > > 13 B12 20030303 1301 914 1 . 1 > > 14 B11 20030303 1301 915 1 . . > > 15 B12 20030303 1301 915 2 . 1 > > 16 B12 20030303 1301 917 1 . 1 > > 17 B12 20030303 1301 918 1 . 1 > > 18 B12 20030303 1301 931 2 . . > > 19 B12 20030303 1301 932 1 . . > > 20 B11 20030303 1301 933 5 . . > > 21 B12 20030303 1301 933 6 . . > > 22 B12 20030303 1301 934 1 . . > > 23 B12 20030303 1301 934 3 . . > > 24 B11 20030303 1301 934 5 2 . > > 25 B12 20030303 1301 934 6 . 2 > > 26 B12 20030303 1301 935 1 . 2 > > 27 B12 20030303 1301 936 1 . 2 > > 28 B11 20030303 1301 937 1 . . > > 29 B12 20030303 1301 937 2 . 2 > > 30 B12 20030303 1301 937 4 . 2 > > 31 B11 20030303 1301 939 1 . . > > 32 B12 20030303 1301 939 2 . . > > 33 B12 20030303 1301 955 1 . . > > 34 B11 20030303 1301 956 1 . . > > 35 B12 20030303 1301 956 2 . . > > 36 B11 20030303 1301 957 1 . . > > 37 B12 20030303 1301 957 2 . . > > 38 B12 20030303 1301 957 4 . . > > 39 B11 20030303 1301 958 1 3 . > > 40 B12 20030303 1301 958 2 . 3 > > 41 B11 20030303 1301 959 1 . . > > > HTH > > > Ya > > Hi, You may do not see it clearly, I want the following five minutes > data, not the following five observation. Following you program, I try > many time to edit to meet my requirement, but it still did not work. > So could you make some change in the program? > Thanks. > -Xiaofei- Hide quoted text - > > - Show quoted text - What do you mean by "data". Aren't the flagged five observations "data"? If you want only those flagged observations, you can simply add one line: if ^missing(flag) then output;
From: Ya on 9 Aug 2010 14:33 On Aug 9, 11:28 am, Ya <huang8...(a)gmail.com> wrote: > On Aug 9, 11:17 am, William <shawfee....(a)gmail.com> wrote: > > > > > > > On Aug 10, 12:23 am, Ya <huang8...(a)gmail.com> wrote: > > > > On Aug 8, 10:06 pm, William <shawfee....(a)gmail.com> wrote: > > > > > On Aug 9, 12:51 pm, Barry Schwarz <schwa...(a)dqel.com> wrote: > > > > > > Sort by type, date, and time. > > > > > > Loop through observations. > > > > > When you reach one with an index of interest, compute the end > > > > > time of interest and retain the index value and end time. Also set a > > > > > flag indicating that index should be updated. > > > > > If the update flag is set, check the time against end time. When > > > > > less, update index. When not, reset the update flag. > > > > > > On Sun, 8 Aug 2010 21:07:04 -0700 (PDT), William > > > > > > <shawfee....(a)gmail.com> wrote: > > > > > >data example: > > > > > >obs type date id time number index > > > > > >1 B11 20030303 1301 900 1 > > > > > >2 B12 20030303 1301 900 2 > > > > > >3 B12 20030303 1301 902 1 > > > > > >4 B12 20030303 1301 904 1 > > > > > >5 B11 20030303 1301 905 1 > > > > > >6 B12 20030303 1301 905 2 > > > > > >7 B12 20030303 1301 910 3 > > > > > >8 B12 20030303 1301 910 5 > > > > > >9 B12 20030303 1301 911 1 > > > > > >10 B12 20030303 1301 913 1 > > > > > >11 B11 20030303 1301 913 3 1 > > > > > >12 B12 20030303 1301 913 4 > > > > > >13 B12 20030303 1301 914 1 > > > > > >14 B11 20030303 1301 915 1 > > > > > >15 B12 20030303 1301 915 2 > > > > > >16 B12 20030303 1301 917 1 > > > > > >17 B12 20030303 1301 918 1 > > > > > >18 B12 20030303 1301 931 2 > > > > > >19 B12 20030303 1301 932 1 > > > > > >20 B11 20030303 1301 933 5 > > > > > >21 B12 20030303 1301 933 6 > > > > > >22 B12 20030303 1301 934 1 > > > > > >23 B12 20030303 1301 934 3 > > > > > >24 B11 20030303 1301 934 5 2 > > > > > >25 B12 20030303 1301 934 6 > > > > > >26 B12 20030303 1301 935 1 > > > > > >27 B12 20030303 1301 936 1 > > > > > >28 B11 20030303 1301 937 1 > > > > > >29 B12 20030303 1301 937 2 > > > > > >30 B12 20030303 1301 937 4 > > > > > >31 B11 20030303 1301 939 1 > > > > > >32 B12 20030303 1301 939 2 > > > > > >33 B12 20030303 1301 955 1 > > > > > >34 B11 20030303 1301 956 1 > > > > > >35 B12 20030303 1301 956 2 > > > > > >36 B11 20030303 1301 957 1 > > > > > >37 B12 20030303 1301 957 2 > > > > > >38 B12 20030303 1301 957 4 > > > > > >39 B11 20030303 1301 958 1 3 > > > > > >40 B12 20030303 1301 958 2 > > > > > >41 B11 20030303 1301 959 1 > > > > > > >when type=B11 and index=1, time is 9:13, I want to get the following > > > > > >five minutes observation and type=B12, > > > > > > >for example, > > > > > >when type=B11 and index=1, time is 9:13, I want to get the following > > > > > >five minutes observation, that is to say get the observation from 12, > > > > > >13, 15, 16, 17 and have a varable flag equal index=1. > > > > > > >when type=B11 and index=2, time is 9:34, I want to get the following > > > > > >five minutes observation, that is to say get the observation from 25, > > > > > >26, 27, 29, 30, 32 and have a varable flag equal index=2. etc. > > > > > > >My data have millions of observation, different id, different date, > > > > > >different time, different number, and the index has more 20,000. How > > > > > >to solve this question? > > > > > > >Thank you so much! > > > > > >-Xiaofei > > > > > > -- > > > > > Remove del for email > > > > > proc sort data=a; by type date time; run; > > > > > Then I do not know what to do, I do not understand it clearly. Can you > > > > write down the program? Thanks. > > > > -Xiaofei- Hide quoted text - > > > > > - Show quoted text - > > > > data need; > > > set example; > > > retain flag0; > > > if ^missing(index) then do; > > > n_=0; flag0=index; end; > > > if type='B12' then n_+1; > > > if n_<=5 and type='B12' then flag=flag0; > > > drop flag0 n_; > > > run; > > > > proc print; > > > run; > > > > obs type date id time number index flag > > > > 1 B11 20030303 1301 900 1 . . > > > 2 B12 20030303 1301 900 2 . . > > > 3 B12 20030303 1301 902 1 . . > > > 4 B12 20030303 1301 904 1 . . > > > 5 B11 20030303 1301 905 1 . . > > > 6 B12 20030303 1301 905 2 . . > > > 7 B12 20030303 1301 910 3 . . > > > 8 B12 20030303 1301 910 5 . . > > > 9 B12 20030303 1301 911 1 . . > > > 10 B12 20030303 1301 913 1 . . > > > 11 B11 20030303 1301 913 3 1 . > > > 12 B12 20030303 1301 913 4 . 1 > > > 13 B12 20030303 1301 914 1 . 1 > > > 14 B11 20030303 1301 915 1 . . > > > 15 B12 20030303 1301 915 2 . 1 > > > 16 B12 20030303 1301 917 1 . 1 > > > 17 B12 20030303 1301 918 1 . 1 > > > 18 B12 20030303 1301 931 2 . . > > > 19 B12 20030303 1301 932 1 . . > > > 20 B11 20030303 1301 933 5 . . > > > 21 B12 20030303 1301 933 6 . . > > > 22 B12 20030303 1301 934 1 . . > > > 23 B12 20030303 1301 934 3 . . > > > 24 B11 20030303 1301 934 5 2 . > > > 25 B12 20030303 1301 934 6 . 2 > > > 26 B12 20030303 1301 935 1 . 2 > > > 27 B12 20030303 1301 936 1 . 2 > > > 28 B11 20030303 1301 937 1 . . > > > 29 B12 20030303 1301 937 2 . 2 > > > 30 B12 20030303 1301 937 4 . 2 > > > 31 B11 20030303 1301 939 1 . . > > > 32 B12 20030303 1301 939 2 . . > > > 33 B12 20030303 1301 955 1 . . > > > 34 B11 20030303 1301 956 1 . . > > > 35 B12 20030303 1301 956 2 . . > > > 36 B11 20030303 1301 957 1 . . > > > 37 B12 20030303 1301 957 2 . . > > > 38 B12 20030303 1301 957 4 . . > > > 39 B11 20030303 1301 958 1 3 . > > > 40 B12 20030303 1301 958 2 . 3 > > > 41 B11 20030303 1301 959 1 . . > > > > HTH > > > > Ya > > > Hi, You may do not see it clearly, I want the following five minutes > > data, not the following five observation. Following you program, I try > > many time to edit to meet my requirement, but it still did not work. > > So could you make some change in the program? > > Thanks. > > -Xiaofei- Hide quoted text - > > > - Show quoted text - > > What do you mean by "data". Aren't the flagged five observations > "data"? > If you want only those flagged observations, you can simply add one > line: > > if ^missing(flag) then output;- Hide quoted text - > > - Show quoted text - Ok, I guess I know what you want now. I'll try to modify the code and see it it works.
From: Ya on 9 Aug 2010 14:44 On Aug 9, 11:33 am, Ya <huang8...(a)gmail.com> wrote: > On Aug 9, 11:28 am, Ya <huang8...(a)gmail.com> wrote: > > > > > On Aug 9, 11:17 am, William <shawfee....(a)gmail.com> wrote: > > > > On Aug 10, 12:23 am, Ya <huang8...(a)gmail.com> wrote: > > > > > On Aug 8, 10:06 pm, William <shawfee....(a)gmail.com> wrote: > > > > > > On Aug 9, 12:51 pm, Barry Schwarz <schwa...(a)dqel.com> wrote: > > > > > > > Sort by type, date, and time. > > > > > > > Loop through observations. > > > > > > When you reach one with an index of interest, compute the end > > > > > > time of interest and retain the index value and end time. Also set a > > > > > > flag indicating that index should be updated. > > > > > > If the update flag is set, check the time against end time. When > > > > > > less, update index. When not, reset the update flag. > > > > > > > On Sun, 8 Aug 2010 21:07:04 -0700 (PDT), William > > > > > > > <shawfee....(a)gmail.com> wrote: > > > > > > >data example: > > > > > > >obs type date id time number index > > > > > > >1 B11 20030303 1301 900 1 > > > > > > >2 B12 20030303 1301 900 2 > > > > > > >3 B12 20030303 1301 902 1 > > > > > > >4 B12 20030303 1301 904 1 > > > > > > >5 B11 20030303 1301 905 1 > > > > > > >6 B12 20030303 1301 905 2 > > > > > > >7 B12 20030303 1301 910 3 > > > > > > >8 B12 20030303 1301 910 5 > > > > > > >9 B12 20030303 1301 911 1 > > > > > > >10 B12 20030303 1301 913 1 > > > > > > >11 B11 20030303 1301 913 3 1 > > > > > > >12 B12 20030303 1301 913 4 > > > > > > >13 B12 20030303 1301 914 1 > > > > > > >14 B11 20030303 1301 915 1 > > > > > > >15 B12 20030303 1301 915 2 > > > > > > >16 B12 20030303 1301 917 1 > > > > > > >17 B12 20030303 1301 918 1 > > > > > > >18 B12 20030303 1301 931 2 > > > > > > >19 B12 20030303 1301 932 1 > > > > > > >20 B11 20030303 1301 933 5 > > > > > > >21 B12 20030303 1301 933 6 > > > > > > >22 B12 20030303 1301 934 1 > > > > > > >23 B12 20030303 1301 934 3 > > > > > > >24 B11 20030303 1301 934 5 2 > > > > > > >25 B12 20030303 1301 934 6 > > > > > > >26 B12 20030303 1301 935 1 > > > > > > >27 B12 20030303 1301 936 1 > > > > > > >28 B11 20030303 1301 937 1 > > > > > > >29 B12 20030303 1301 937 2 > > > > > > >30 B12 20030303 1301 937 4 > > > > > > >31 B11 20030303 1301 939 1 > > > > > > >32 B12 20030303 1301 939 2 > > > > > > >33 B12 20030303 1301 955 1 > > > > > > >34 B11 20030303 1301 956 1 > > > > > > >35 B12 20030303 1301 956 2 > > > > > > >36 B11 20030303 1301 957 1 > > > > > > >37 B12 20030303 1301 957 2 > > > > > > >38 B12 20030303 1301 957 4 > > > > > > >39 B11 20030303 1301 958 1 3 > > > > > > >40 B12 20030303 1301 958 2 > > > > > > >41 B11 20030303 1301 959 1 > > > > > > > >when type=B11 and index=1, time is 9:13, I want to get the following > > > > > > >five minutes observation and type=B12, > > > > > > > >for example, > > > > > > >when type=B11 and index=1, time is 9:13, I want to get the following > > > > > > >five minutes observation, that is to say get the observation from 12, > > > > > > >13, 15, 16, 17 and have a varable flag equal index=1. > > > > > > > >when type=B11 and index=2, time is 9:34, I want to get the following > > > > > > >five minutes observation, that is to say get the observation from 25, > > > > > > >26, 27, 29, 30, 32 and have a varable flag equal index=2. etc. > > > > > > > >My data have millions of observation, different id, different date, > > > > > > >different time, different number, and the index has more 20,000. How > > > > > > >to solve this question? > > > > > > > >Thank you so much! > > > > > > >-Xiaofei > > > > > > > -- > > > > > > Remove del for email > > > > > > proc sort data=a; by type date time; run; > > > > > > Then I do not know what to do, I do not understand it clearly. Can you > > > > > write down the program? Thanks. > > > > > -Xiaofei- Hide quoted text - > > > > > > - Show quoted text - > > > > > data need; > > > > set example; > > > > retain flag0; > > > > if ^missing(index) then do; > > > > n_=0; flag0=index; end; > > > > if type='B12' then n_+1; > > > > if n_<=5 and type='B12' then flag=flag0; > > > > drop flag0 n_; > > > > run; > > > > > proc print; > > > > run; > > > > > obs type date id time number index flag > > > > > 1 B11 20030303 1301 900 1 . . > > > > 2 B12 20030303 1301 900 2 . . > > > > 3 B12 20030303 1301 902 1 . . > > > > 4 B12 20030303 1301 904 1 . . > > > > 5 B11 20030303 1301 905 1 . . > > > > 6 B12 20030303 1301 905 2 . . > > > > 7 B12 20030303 1301 910 3 . . > > > > 8 B12 20030303 1301 910 5 . . > > > > 9 B12 20030303 1301 911 1 . . > > > > 10 B12 20030303 1301 913 1 . . > > > > 11 B11 20030303 1301 913 3 1 . > > > > 12 B12 20030303 1301 913 4 . 1 > > > > 13 B12 20030303 1301 914 1 . 1 > > > > 14 B11 20030303 1301 915 1 . . > > > > 15 B12 20030303 1301 915 2 . 1 > > > > 16 B12 20030303 1301 917 1 . 1 > > > > 17 B12 20030303 1301 918 1 . 1 > > > > 18 B12 20030303 1301 931 2 . . > > > > 19 B12 20030303 1301 932 1 . . > > > > 20 B11 20030303 1301 933 5 . . > > > > 21 B12 20030303 1301 933 6 . . > > > > 22 B12 20030303 1301 934 1 . . > > > > 23 B12 20030303 1301 934 3 . . > > > > 24 B11 20030303 1301 934 5 2 . > > > > 25 B12 20030303 1301 934 6 . 2 > > > > 26 B12 20030303 1301 935 1 . 2 > > > > 27 B12 20030303 1301 936 1 . 2 > > > > 28 B11 20030303 1301 937 1 . . > > > > 29 B12 20030303 1301 937 2 . 2 > > > > 30 B12 20030303 1301 937 4 . 2 > > > > 31 B11 20030303 1301 939 1 . . > > > > 32 B12 20030303 1301 939 2 . . > > > > 33 B12 20030303 1301 955 1 . . > > > > 34 B11 20030303 1301 956 1 . . > > > > 35 B12 20030303 1301 956 2 . . > > > > 36 B11 20030303 1301 957 1 . . > > > > 37 B12 20030303 1301 957 2 . . > > > > 38 B12 20030303 1301 957 4 . . > > > > 39 B11 20030303 1301 958 1 3 . > > > > 40 B12 20030303 1301 958 2 . 3 > > > > 41 B11 20030303 1301 959 1 . . > > > > > HTH > > > > > Ya > > > > Hi, You may do not see it clearly, I want the following five minutes > > > data, not the following five observation. Following you program, I try > > > many time to edit to meet my requirement, but it still did not work. > > > So could you make some change in the program? > > > Thanks. > > > -Xiaofei- Hide quoted text - > > > > - Show quoted text - > > > What do you mean by "data". Aren't the flagged five observations > > "data"? > > If you want only those flagged observations, you can simply add one > > line: > > > if ^missing(flag) then output;- Hide quoted text - > > > - Show quoted > > ... > > read more »- Hide quoted text - > > - Show quoted text - Ok, this should do it: data need; set example; retain flag0 startime; if ^missing(index) then do; flag0=index; startime=time; end; if type='B12' and time <= startime +5 then flag=flag0; drop flag0; run; proc print; run; 23 23 B12 20030303 1301 934 3 . 913 . 24 24 B11 20030303 1301 934 5 2 934 . 25 25 B12 20030303 1301 934 6 . 934 2 26 26 B12 20030303 1301 935 1 . 934 2 27 27 B12 20030303 1301 936 1 . 934 2 28 28 B11 20030303 1301 937 1 . 934 . 29 29 B12 20030303 1301 937 2 . 934 2 30 30 B12 20030303 1301 937 4 . 934 2 31 31 B11 20030303 1301 939 1 . 934 . 32 32 B12 20030303 1301 939 2 . 934 2 33 33 B12 20030303 1301 955 1 . 934 . 34 34 B11 20030303 1301 956 1 . 934 . 35 35 B12 20030303 1301 956 2 . 934 . 36 36 B11 20030303 1301 957 1 . 934 . 37 37 B12 20030303 1301 957 2 . 934 . 38 38 B12 20030303 1301 957 4 . 934 . HTH Ya
From: Ya on 9 Aug 2010 15:22 > Ok, this should do it: > > data need; > set example; > retain flag0 startime; > if ^missing(index) then do; flag0=index; startime=time; end; > if type='B12' and time <= startime +5 then flag=flag0; > drop flag0; > run; > > proc print; > run; > > 23 23 B12 20030303 1301 934 > 3 . 913 . > 24 24 B11 20030303 1301 934 5 > 2 934 . > 25 25 B12 20030303 1301 934 > 6 . 934 2 > 26 26 B12 20030303 1301 935 > 1 . 934 2 > 27 27 B12 20030303 1301 936 > 1 . 934 2 > 28 28 B11 20030303 1301 937 > 1 . 934 . > 29 29 B12 20030303 1301 937 > 2 . 934 2 > 30 30 B12 20030303 1301 937 > 4 . 934 2 > 31 31 B11 20030303 1301 939 > 1 . 934 . > 32 32 B12 20030303 1301 939 > 2 . 934 2 > 33 33 B12 20030303 1301 955 > 1 . 934 . > 34 34 B11 20030303 1301 956 > 1 . 934 . > 35 35 B12 20030303 1301 956 > 2 . 934 . > 36 36 B11 20030303 1301 957 > 1 . 934 . > 37 37 B12 20030303 1301 957 > 2 . 934 . > 38 38 B12 20030303 1301 957 > 4 . 934 . > > HTH > > Ya The way I calculated the time difference is not robust, depend on your data, we may have better option. Is you time a character or numeric?
From: William on 9 Aug 2010 15:37 On Aug 9, 12:22 pm, Ya <huang8...(a)gmail.com> wrote: > > Ok, this should do it: > > > data need; > > set example; > > retain flag0 startime; > > if ^missing(index) then do; flag0=index; startime=time; end; > > if type='B12' and time <= startime +5 then flag=flag0; > > drop flag0; > > run; > > > proc print; > > run; > > > 23 23 B12 20030303 1301 934 > > 3 . 913 . > > 24 24 B11 20030303 1301 934 5 > > 2 934 . > > 25 25 B12 20030303 1301 934 > > 6 . 934 2 > > 26 26 B12 20030303 1301 935 > > 1 . 934 2 > > 27 27 B12 20030303 1301 936 > > 1 . 934 2 > > 28 28 B11 20030303 1301 937 > > 1 . 934 . > > 29 29 B12 20030303 1301 937 > > 2 . 934 2 > > 30 30 B12 20030303 1301 937 > > 4 . 934 2 > > 31 31 B11 20030303 1301 939 > > 1 . 934 . > > 32 32 B12 20030303 1301 939 > > 2 . 934 2 > > 33 33 B12 20030303 1301 955 > > 1 . 934 . > > 34 34 B11 20030303 1301 956 > > 1 . 934 . > > 35 35 B12 20030303 1301 956 > > 2 . 934 . > > 36 36 B11 20030303 1301 957 > > 1 . 934 . > > 37 37 B12 20030303 1301 957 > > 2 . 934 . > > 38 38 B12 20030303 1301 957 > > 4 . 934 . > > > HTH > > > Ya > > The way I calculated the time difference is not robust, depend on your > data, we may have better option. > Is you time a character or numeric? I want to the following five minutes data, include all of the variables, such as, obs, type, coid, date, time, num, flag. The time is character, I can transfer it into time format.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Estimating the value for the functional form of the variance Next: Need help--Cross Table |