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: A problem with reshape


From   ofran almossawi <[email protected]>
To   [email protected]
Subject   Re: st: A problem with reshape
Date   Sun, 14 Jul 2013 23:30:37 +0100

This is the complete code I typed:
gen co1 (contains primary)
gen co2 (contains secondary)
gen co3 (contains co-morbidity)
gen co4 (prodecures)
gen id = _n
reshape long co, i(id) j(num)
egen group = group(id type)
by group, sort: replace num = _n (and this is where the problem is encountered)

thank you

On 14 July 2013 23:09, Conor Hughes <[email protected]> wrote:
> Stata is looking for a variable called "group". There is no such
> variable in the example data you provided. If you did create a group
> variable, please post the code you used to create it as well.
>
> Best,
> Conor
>
> On Sun, Jul 14, 2013 at 6:00 PM, ofran almossawi
> <[email protected]> wrote:
>> Hello
>> I am having some problems with reshape. my data set is rather large
>> and i cannot make the changes by hand.
>> I have data that have no unique identifier, see example of my data below:
>>
>> id   disease   type
>>
>> 1     A              comorbidity
>> 1     B              primary
>> 1     C             comorbidity
>> 2     D             primary
>> 2     E              secondary
>> 2     F             comorbidity
>> 3     G             primary
>> 3     H              comorbidity
>> 3     I                comorbidity
>> 3     J              comorbidity
>>
>> the problem that i am having is creating comorbidity 1, 2, 3 etc and
>> reshaping the data into wide format.
>>
>> I have followed the example at
>> http://www.stata.com/support/faqs/data-management/problems-with-reshape/
>>
>> but when I get to the line "by group, sort: replace no = _n" I get a
>> "0 replacements made" message.
>>
>> I am not sure where I am going wrong with this or if there is a better
>> way of doing it.
>>
>> many thanks in advance.
>> *
>> *   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/
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index