Hello. I have a question for anyone who can answer. I want to create variables for different meeting dates between my organisation and a few people. The reason for that is that I want to calculate the median of the lapsed time between meetings. However, my problem is that not all the people have an equal number of meetings. So will I have the problem with calculating the time? Should I attempt putting something equivalent to a missing value or will that mess up my results? Thanks in advance for any replies.
|
It would be extremely helpful to know whether the data structure is long or wide. Let's suppose it's long. So your file might be like this.
Person meetingdate Aa 1/23/2014 Bb 1/24/2014 Aa 2/12/2014 Aa 2/38/2014 Bb 4/23/2014 Etc. So, that's your dataset. Then. Sort cases by person meetingdate. If (person eq lag(person)) interval=datediff(meetingdate,lag(meetingdate),"days"). Aggregate outfile=*/break=person/medianinterval=median(interval). Note. It may be that datediff won't allow the lag function. If that is true, then change the code as follows. Sort ... Compute #dd=lag(meetingdate). If (person eq lag(person)) interval=datediff(meetingdate,#dd),"days"). Gene Maguin -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Artemis Chris Sent: Monday, February 02, 2015 9:28 AM To: [hidden email] Subject: Missing Dates and calculations of lapsed time Hello. I have a question for anyone who can answer. I want to create variables for different meeting dates between my organisation and a few people. The reason for that is that I want to calculate the median of the lapsed time between meetings. However, my problem is that not all the people have an equal number of meetings. So will I have the problem with calculating the time? Should I attempt putting something equivalent to a missing value or will that mess up my results? Thanks in advance for any replies. -- View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Missing-Dates-and-calculations-of-lapsed-time-tp5728560.html Sent from the SPSSX Discussion mailing list archive at Nabble.com. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by Artemis Chris
At 09:28 AM 2/2/2015, Artemis Chris wrote:
>I want to create variables for different meeting dates between my >organization and a few people. The reason for that is that I want to >calculate the median of the lapsed time between meetings. So, you'll have one record ('case') per person, and a number of meeting dates in that record? >However, my problem is that not all the people have an equal number >of meetings. So will I have the problem with calculating the time? >Should I attempt putting something equivalent to a missing value or >will that mess up my results? It's perfectly possible to have missing values for date variables. To start off with, they're numeric variables, so can be system-missing (SYSMIS). You can also assign user-missing values to date variables: from the Command Syntax Reference (v.22) article on MISSING VALUES: >>For date format variables (for example, DATE, ADATE), missing >>values expressed in date formats must be enclosed in single or >>double quotes, and values must be expressed in the same date format >>as the defined date format for the variable. However, let me suggest an alternative. The data organization you're talking about, with multiple dates in single records, is called 'wide' form. It may be better to use 'long' form, with one record for each meeting of each person; then, you can have records for however many meetings occur for any person, and there's no need to fill in missing values for persons who have fewer meetings. The inter-meeting time is then something like (UNTESTED), NUMERIC InterTime (F4). VAR LABEL InterTime 'Time, days, since previous meeting'. DO IF $CASENUM GT 1 AND Person EQ LAG(Person). . COMPUTE InterTime = CTIME.DAYS(Date - LAG(Date)). END IF. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
In reply to this post by Maguin, Eugene
Hey, so the form roughly is:
PersonA PersonB date of first meeting date of first meeting date of second meeting date of second meeting date of third meeting date of third meeting etc. etc. and the maximum of people, so far is 560 and the maximum number of meetings is 20 or so, but most of the people have along the lines of 3 or so meetings. In any case I will try your suggestion, thank you. |
In reply to this post by Richard Ristow
Also, I did think about having a separate record for each meeting, I just thought it might turn complicated in the long run, since we will keep on collecting data and we would like to compare the time that passes between the meetings with the rest of our data.
I know, I am probably making my life really complicated, I just thought I might give it a try. Thank you for the answers. |
Free forum by Nabble | Edit this page |