```Date: Thu, 5 Aug 1999 09:58:48 +0100 Reply-To: tra Sender: "SAS(r) Discussion" Comments: To: JGerstle@SW.UA.EDU From: tra Organization: Proteus Molecular Design Ltd Subject: Re: A Challenging Problem Comments: To: SAS-L@LISTSERV.VT.EDU Content-Type: text/plain; charset=us-ascii John, what an interesting problem. Here is a partial solution in sql. I hope it is self-explanatory. For the data you supply, there seems to be perfect agreement between the two raters (given the 1 second leeway) as every state seen by rater 1 was also seen by rater 2. I have not tested the code, except on the data you supplied. Hope this helps Tim Auton data test; length id code 8 key \$ 1 start end 8; input id code key start end; datlines; 2001 1 V 04 10 2001 1 B 10 15 2001 1 V 15 16 2001 1 N 16 30 2001 1 P 17 17 2001 1 V 30 35 2001 1 \ 35 35 2002 1 V 10 15 2002 1 B 15 20 2002 1 P 17 17 2002 1 V 20 35 2002 1 \ 35 35 2001 2 V 05 10 2001 2 B 10 16 2001 2 V 16 17 2001 2 N 17 30 2001 2 P 18 18 2001 2 V 30 36 2001 2 \ 36 36 2002 2 V 9 15 2002 2 B 15 21 2002 2 P 17 17 2002 2 V 21 37 2002 2 \ 37 37 ; %print; proc sql; create table matches as select a.id, a.key, max(a.start, b.start-1) as start, min(a.end, b.end+1) as end from test a, test b where a.id = b.id and a.key = b.key and a.code = 1 and b.code = 2 and calculated start <= calculated end order by key, id, calculated start, calculated end ; create table matchsum as select key, /* P is an event code, so duration would be zero, To handle events as well as states which have a duration in the same code, add one second to each occurence of an event. */ sum(end-start + (key in ('P'))) as duration from matches group by key; /* events seen by rater 1 during period of observation of rater 2 (with 1 second leeway) */ create table common as select a.id, a.key, max(a.start, b.start-1) as start, min(a.end, b.end+1) as end from test a, test b where a.id = b.id and a.code = 1 and b.code = 2 and calculated start <= calculated end order by key, id, calculated start, calculated end ; create table obssum as select key, sum(end-start + (key in ('P'))) as duration from common where code = 1 group by key; create table kappa as select o.key, o.duration, m.duration as durmatch, m.duration/o.duration as kappa from obssum o, matchsum m where o.key = m.key order by key; select * from kappa; quit; JGerstle@SW.UA.EDU wrote: > Greetings and Salutations All > I posted a question last week about sequential analyses via > SAS and received some responses that I could use SAS/ETS. > Thank you for the info. Unfortunately, we do not have this module. > > As my subject line indicates, I have somewhat a challenge to > any of you that have the time to come up with some sort of plan to > address the problem I'm going to relate. First, I should tell you that > I am using SAS 6.12 for Windows 95. What I'm looking for are > ideas and clues that will, hopefully, lead me to solve my problem. > OK, onto the actual query. > > I have a dataset (shown at the bottom) that was put together > from several flat files created via a BASICA program that we use to > do our observational data collection on residents in nursing homes. > The program, in a nutshell, asks for certain header info (name, id, > date, etc..) and then starts recording, using the internal clock of > the laptop, the start and stop times, in seconds, of several different > behaviors which are represented by various keys on the keyboard > (i.e. 'V' for disruptive behavior, 'B' for talking to self, 'N' for talking to > another resident, etc.). > I wrote a SAS program (I will send a copy for any that are > interested personally) that wil read in the hundreds of flat files > containing this info and separate the header and data portions of > the files into separate datasets. Then I can simply do the analyses > I need to do (like keypercents). The problem I need to address is a > way to calculate reliability kappas for a pair of primary and rely flat > files. The procedure we have now uses a couple of Pascal > programs, but the composer of these programs does not work with > us anymore and we have the need to modify how we calculate our > kappas. > Now some of our keys are event keys, only 'on' for a second, > while the rest are duration keys, 'on' for several seconds. We want > to give a one second window on either side of both types of keys > so if one of the raters is off by a second with the onset of a key, > the kappa program will take this into account and not discount the > lost second. > > Here's a sample dataset with variable names ID, Primary/Rely > Code (1 for primary, 2 for rely), KEY, START time, END time: > (Keys V, B, & N are duration and key P is event, / is used aas > end of file). The length of the file (the total number of seconds) and > the number of lines of data are the last two lines of the header, > which can be merged with the data and used. > > 2001 1 V 04 10 > 2001 1 B 10 15 > 2001 1 V 15 16 > 2001 1 N 16 30 > 2001 1 P 17 17 > 2001 1 V 30 35 > 2001 1 \ 35 35 > 2002 1 V 10 15 > 2002 1 B 15 20 > 2002 1 P 17 17 > 2002 1 V 20 35 > 2002 1 \ 35 35 > 2001 2 V 05 10 > 2001 2 B 10 16 > 2001 2 V 16 17 > 2001 2 N 17 30 > 2001 2 P 18 18 > 2001 2 V 30 36 > 2001 2 \ 36 36 > 2002 2 V 9 15 > 2002 2 B 15 21 > 2002 2 P 17 17 > 2002 2 V 21 37 > 2002 2 \ 37 37 > > etc...... > > Thank you much for any ideas and leads that you may come up > with... > > John Gerstle > Program Analyst, Sr. > Applied Gerontology Program > University of Alabama -- T R Auton PhD MSc C.Math Head of Biomedical Statistics Proteus Molecular Design Ltd Beechfield House Lyme Green Business Park Macclesfield Cheshire SK11 0JL UK email: tra@proteus.co.uk ```

Back to: Top of message | Previous page | Main SAS-L page