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]

st: reshape more than one variable


From   Daniel Exeter <[email protected]>
To   "'[email protected]'" <[email protected]>
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index