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: reshape more than one variable


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: reshape more than one variable
Date   Mon, 18 Jun 2012 09:27:56 +0100

I don't understand how this could work, because it implies multiple
successive -reshape wide-s.

So I suspect that you are not showing us most of your code, perhaps
code that saves each version of the data and reads in the original
again.

However, there is no problem in principle with the idea that the -i()-
option indicating what identifies distinct records specifies two or
more variables. The syntax is that it takes a varlist and there are
examples in the help and in the FAQs thrown up by -search reshape-.

That said, most -reshape wide-s make analysis more difficult.

Nick

On Mon, Jun 18, 2012 at 5:32 AM, Daniel Exeter <[email protected]> wrote:

> I have the code
>
> Foreach geog  in county region {
> Foreach oc in heart stroke {
> Foreach s in gender age ses {
>
> *do stuff and create variables "pr uci lci pop"
>
> Reshape wide uci lci pr pop ,  i(`geog') j(`s')
> }
> }
> }
>
> Which works fine, but I am struggling to do more than one variable for the reshape.
>
>
> For example, how could I get  a reshape to work for
> Outcomes by `geog' `s' and `var2'
> Or indeed
> Outcomes by `geog' `s'  `var2' and 'var3'
>
>
> The code below:
>
>
> Foreach geog  in county region {
> Foreach oc in heart stroke {
> Foreach s in gender age {
> Foreach var2 in ses dep ethnicity {
>
> *do stuff and create variables "pr uci lci pop"
>
> Reshape wide uci lci pr pop,  i(`geog') j(`s' `var2')
> }
> }
> }
> }
>
>
> Returns the error:
> Ses is not unique within county;
> There are multiple observations  at the same ses within county;
> ...

*
*   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