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]

st: reshape more than one variable


From   Daniel Exeter <d.exeter@auckland.ac.nz>
To   "'statalist-digest@hsphsun2.harvard.edu'" <statalist-digest@hsphsun2.harvard.edu>
Subject   st: reshape more than one variable
Date   Mon, 18 Jun 2012 04:32:16 +0000

Hi there

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;
... 

Any ideas how to overcome this would be fantastic,

Thanks in advance. 

Cheers
Dan

 

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