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 on April 23, and its replacement, statalist.org is already up and running.


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

RE: st: reshape to keep single age range and multiple years


From   Tim Evans <Tim.Evans@wmciu.nhs.uk>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: reshape to keep single age range and multiple years
Date   Fri, 23 Nov 2012 14:25:57 +0000

Scott,

Thanks for that, worked a treat!

Best wishes

Tim

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Scott Merryman
Sent: 22 November 2012 18:27
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: reshape to keep single age range and multiple years

drop id
reshape wide count , i(yy) j(age)

Scott


On Thu, Nov 22, 2012 at 11:16 AM, Tim Evans <Tim.Evans@wmciu.nhs.uk> wrote:
> Hi all,
>
> I'm using Stata 11.2 and I've collapsed an individual data set so that I have year, counts of tumours and age at diagnosis. I have multiple years of diagnosis, with single year of age starting from 16 - 100+.
>
> The data look like this:
>
> id      yydx    count   age_at_diag
> 1       1998    1       22
> 2       1998    1       25
> 3       1998    2       26
> 4       1998    4       27
> 5       1998    2       29
> 6       1998    1       31
> 7       1998    2       32
> 8       1998    1       33
> 9       1998    1       35
> 10      1998    2       36
> 11      1998    3       37
> 12      1998    1       38
> 13      1998    9       39
> 14      1998    4       40
> 15      1998    6       41
> 16      1998    8       42
> 17      1998    5       43
> 18      1998    8       44
> 19      1998    10      45
> 20      1998    10      46
> 21      1998    20      47
> 22      1998    23      48
> 23      1998    17      49
> 24      1998    25      50
> 25      1998    31      51
> 26      1998    26      52
> 27      1998    37      53
>
>
> The data continue so that yydx continues until 2010.
>
> What I would like to do and am having trouble doing, is reshape the data so that I have year running down the dataset and age at diag running across the data set like thus
>
>         16      17      18      19 and so on
> 1999 5  0    14
> 1999    1       2       21
> 2000    3       1       19
>
> Does anyone have any suggestions please?
>
> Best wishes
>
> Tim
>
>
>
> _DISCLAIMER:
> This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful.
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

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

_DISCLAIMER:
This email and any attachments hereto contains proprietary information, some or all of which may be confidential or legally privileged. It is for the exclusive use of the intended recipient(s) only. If an addressing or transmission error has misdirected this e-mail and you are not the intended recipient(s), please notify the author by replying to this e-mail. If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail or any attachments, as this may be unlawful.


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


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index