Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: expanding data set by variable


From   KOTa <kota.alba@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: expanding data set by variable
Date   Tue, 8 May 2012 20:18:59 -0400

thanks for quick response, Nick

> 1. What the date variables are (string, numeric, numeric with a date format)?

sorry i just didnt think to mention this, cause it can easily
converted among those formats you listed. ( and i actually have dates
in all 3 of them)

> 2. Why you think the second data structure is going to be a good one?

what i am trying to do is to count the time spent on each "type" of
activity. which i already figured out how to do (with the help from
the statalist )
but the problem is if activities overlap in days for same person and i
dont take account for this - i over-count them both.
so what i tried to do is to split time equally among requests (ID)
that happened at the same time(for same user). i managed to do this
for requests (ID) that start at the same time, but could not find a
way to do this if they start at different times (and it can be overlap
between more then 2 requests). the aprouch i though to take is to
recode the data so each observation would be split into not
overlapping periods.

> If this were my data, I would get a different structure this way:
> ...
> gen mydate = date(string(start, "%12.0f"), "YMD")
> gen mydate2 = date(string(end, "%12.0f"), "YMD")
> format mydate %td
> gen length = mydate2 - mydate + 1

that is how i started

> expand length

that what i wanted to do, but could not find in the help or examples
if "expand" can be used this way

> bysort ID : replace mydate = mydate + _n - 1

1. i forgot to mention that the count has to be by activity type. so,
correct me if i wrong the bysort then should be "bysort ID type" ..."
2. i didn't understand the logic of replace mydate = mydate + _n - 1


thanks again
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index