Steven A Harvey
>
> A few days back, I posted a question about restructuring multilevel
> data. Nick Cox suggested I send the data structure rather than the
> narrative explanation I originally posted. For some reason, when I
> sent the message below, the original message was posted
> instead. My
> apologies for the repetition, but here is the response to Nick's
> request for clarification. The original message & response appears
> below. Again, many thanks in advance for your suggestions.
> ----------------------------------------------------------
>
> My data is structured as follows. I'm putting the varnames
> in a column
> here rather than a row because of the number of vars. involved.
>
> prov#_id is each individual provider's id number.
>
> prov#_lab, prov#_del, prov#_m, prov#_nn are all dummy variables
> indicating, respectively, whether each provider
> participated in labor
> monitoring, delivery, post partum care for the mother, and
> post partum
> care for the neonate.
>
> obs_no (numeric 1-n)
> [demographic var list]
> prov1_id (numeric)
> prov1_lab (0, 1)
> prov1_del (0, 1)
> prov1_m (0, 1)
> prov1_nn (0, 1)
> prov2_id (numeric)
> prov2_lab (0, 1)
> prov2_del (0, 1)
> prov2_m (0, 1)
> prov2_nn (0, 1)
> .
> .
> .
> prov8_id (numeric)
> prov8_lab (0, 1)
> prov8_del (0, 1)
> prov8_pm (0, 1)
> prov8_pnn (0, 1)
> [explanatory varlist]
>
>
> I've used reshape in other situations. I don't think it
> will work here
> because I need to include the demographic and explanatory
> variables in
> each observation, but generate multiple observations per
> case (woman
> delivering) so that each observation contains information
> about only
> one provider.
Still seems like a -reshape- to me. Don't
worry about the other variables: they
will get carried along. The biggest
issue, itself soluble, is that your variable
names are the wrong way round for -reshape-.
(Other recent threads on Statalist
include similar examples.)
forval i = 1/8 {
foreach s in id lab del m nn {
rename prov`i'_`s' `s'`i'
}
}
reshape long id lab del m nn, id(obs_no)
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/