Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: Data Manipulation


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Data Manipulation
Date   Thu, 7 Apr 2011 10:19:48 +0100

Same answer from me. My ethics preclude me from telling you how to do
something that strikes me as a very bad idea, a dataset for each of
500 persons, but clearly that's no constraint on anybody else.
Otherwise look for -reshape long-. Getting a single date variable

gen date = mdy(act_mm, act_dd,  act_yy)

will help lots of Stata things. Your observations are then jointly
identified by -id date-.

On Thu, Apr 7, 2011 at 9:57 AM, Rajaram Subramanian Potty
<rajara999@gmail.com> wrote:
> This is real data set from a researh study and include arond 500
> persons. In the example, I provided the data of four persons only.
>
> Thanks and regards.
>
> RAM
>
> On Thu, Apr 7, 2011 at 1:59 PM, Nick Cox <njcoxstata@gmail.com> wrote:
>> It is not clear to me what you mean by "a data", which I don't think
>> is widely accepted as a standard form of words. I can't imagine it
>> being printed in the Stata Journal, for example.
>>
>> If you want to create different datasets from this master dataset, my
>> guess is that would make most analyses much more difficult, especially
>> one dataset for each person.
>>
>> Some analyses would be easier with a long data structure in which each
>> sex act was a separate observation. That's a -reshape long-.
>>
>> (I set aside the question of whether this is real data or the research
>> ethical!)
>>
>> Nick
>>
>> On Thu, Apr 7, 2011 at 6:55 AM, Rajaram Subramanian Potty
>> <rajara999@gmail.com> wrote:
>>>
>>> I have one data, each selected persons were followed each day and
>>> enquired about their sex act in each day. For each sex act details
>>> were collected. For example, if the respondent reported 3 acts were
>>> reported, information on all the three sex acts were collected. Now
>>> the data available is for each date. From this data, I wanted to
>>> create a data for each person and also another data for each sex act.
>>> these data set should also include all the variables as well.
>>> Following is an example of the data with few variables for the first 3
>>> sex acts.
>>>
>>> The variable ending with _01, _02, and _03 indicates the 3 sex act in
>>> the same day.
>>>
>>> id      act_dd  act_mm  act_yy  doi_dd  doi_mm  doi_yy  tot_act rep_01  rep_02  rep_03  q1_01   q1_02   q1_03
>>> 20020001        7       2       2011    8       2       2011    3       X       X       X       4       4       3
>>> 20020001        8       2       2011    9       2       2011    1       X                       4
>>> 20020001        9       2       2011    10      2       2011    2       X       X               3       3
>>> 20020001        10      2       2011    11      2       2011    1       X                       1
>>> 20020001        11      2       2011    12      2       2011    0
>>> 20020001        12      2       2011    13      2       2011    2       X       X               4       1
>>> 20020001        13      2       2011    14      2       2011    1       X                       4
>>> 20020001        14      2       2011    16      2       2011    2       X       X               4       4
>>> 20020001        15      2       2011    16      2       2011    2       A       A               2       2
>>> 20020001        16      2       2011    17      2       2011    1       X                       3
>>> 20020002        12      2       2011    13      2       2011    0
>>> 20020002        13      2       2011    14      2       2011    5       A       A       X       1       1       4
>>> 20020002        14      2       2011    15      2       2011    2       A       A               1       1
>>> 20020002        15      2       2011    16      2       2011    2       A       A               4       4
>>> 20020002        16      2       2011    17      2       2011    4       X       A       A       1       4       4
>>> 20020002        17      2       2011    18      2       2011    2       X       X               3       3
>>> 20020003        8       2       2011    9       2       2011    0
>>> 20020003        9       2       2011    10      2       2011    0
>>> 20020003        10      2       2011    11      2       2011    4       A       A       X       4       4       4
>>> 20020003        11      2       2011    12      2       2011    3       X       X       X       3       3       4
>>> 20020003        12      2       2011    13      2       2011    0
>>> 20020003        13      2       2011    14      2       2011    2       X       X               3       3
>>> 20020003        14      2       2011    15      2       2011    3       X       X       X       4       3       1
>>> 20020003        15      2       2011    16      2       2011    3       A       A       X       3       3       3
>>> 20020004        1       3       2011    2       3       2011    0
>>> 20020004        11      2       2011    12      2       2011    1       X                       4
>>> 20020004        12      2       2011    15      2       2011    0
>>> 20020004        13      2       2011    15      2       2011    2       X       X               3       4
>>> 20020004        14      2       2011    15      2       2011    1       X                       3
>>> 20020004        15      2       2011    18      2       2011    0

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index