Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Reshape problem.


From   "shigui weng" <[email protected]>
To   <[email protected]>
Subject   Re: st: RE: Reshape problem.
Date   Sat, 15 Nov 2003 21:16:17 -0500

It seems you are using a DHS data set. The figure 287 does make sense, it
menas 287 obs with non missing values. In your case, the maximum birth order
is 10, your reshaped long structure data set should have 10 observations for
each case in the original wide format. Please note that not every
participant could have births up to ten (or twenty in a regular DHS data
set), so there must be a lot of missing values. By the way, the total obs in
the reshaped long format should be 80990.

shigui weng
Johns Hopkins University

----- Original Message ----- 
From: <[email protected]>
To: <[email protected]>
Sent: Saturday, November 15, 2003 11:56 AM
Subject: Re: st: RE: Reshape problem.


> Hi John,
>
> Thanks for the reply.
>
> I think I should be provide more description of what I am try to do.
> I have a set of 8099 women. Questions have been asked on the
> number of chidlren and whether they are still leaving or not.
> I want to reshape the dataset in order to have a dataset of the children.
>
>
> . use "C:\Documents and Settings\Desktop\womendata.dta", clear
> . count
>  8099
> . sort caseid
> . g wid=_n
>
> . d
> bidx_01         byte   %2.0f                  Birth column number
> bord_01         byte   %2.0f                  Birth order number
> b0_01           byte   %1.0f       b0_01      Child is twin
> b1_01           byte   %2.0f                  Month of birth
> b2_01           byte   %2.0f                  Year of birth
> b3_01           int    %4.0f                  Date of birth (CMC)
> b4_01           byte   %1.0f       b4_01      Sex of child
> b5_01           byte   %1.0f       b5_01      Child is alive
> b6_01           int    %3.0f       b6_01      Age at death
> b7_01           int    %3.0f                  Age at death
(months-imputed)
> b8_01           byte   %2.0f                  Current age of child
> b9_01           byte   %1.0f       b9_01      Who child lives with
> b10_01          byte   %1.0f       b10_01     Completeness of information
> b11_01          int    %3.0f                  Preceding birth interval
> b12_01          byte   %3.0f                  Succeeding birth interval
> b13_01          byte   %1.0f       b13_01     Flag for age at death
> b14_01          byte   %1.0f       b14_01     Birth interval >= 4 years -
NA
> b15_01          byte   %1.0f       b15_01     Live birth between births -
NA
> bidx_02         byte   %2.0f                  Birth column number
> bord_02         byte   %2.0f                  Birth order number
> b0_02           byte   %1.0f       b0_02      Child is twin
> b1_02           byte   %2.0f                  Month of birth
> b2_02           byte   %2.0f                  Year of birth
> b3_02           int    %4.0f                  Date of birth (CMC)
> b4_02           byte   %1.0f       b4_02      Sex of child
> b5_02           byte   %1.0f       b5_02      Child is alive
> b6_02           int    %3.0f       b6_02      Age at death
> b7_02           int    %3.0f                  Age at death
(months-imputed)
> b8_02           byte   %2.0f                  Current age of child
> b9_02           byte   %1.0f       b9_02      Who child lives with
> b10_02          byte   %1.0f       b10_02     Completeness of information
> b11_02          int    %3.0f                  Preceding birth interval
> b12_02          int    %3.0f                  Succeeding birth interval
> b13_02          byte   %1.0f       b13_02     Flag for age at death
> b14_02          byte   %1.0f       b14_02     Birth interval >= 4 years -
NA
> b15_02          byte   %1.0f       b15_02     Live birth between births -
NA
> bidx_03         byte   %2.0f                  Birth column number
> bord_03         byte   %2.0f                  Birth order number
> .
> .
> .
> .
> bidx_10         byte   %2.0f                  Birth column number
> bord_10         byte   %2.0f                  Birth order number
> b0_10           byte   %1.0f       b0_10      Child is twin
> b1_10           byte   %2.0f                  Month of birth
> b2_10           byte   %2.0f                  Year of birth
> b3_10           int    %4.0f                  Date of birth (CMC)
> b4_10           byte   %1.0f       b4_10      Sex of child
> b5_10           byte   %1.0f       b5_10      Child is alive
> b6_10           int    %3.0f       b6_10      Age at death
> b7_10           int    %3.0f                  Age at death
(months-imputed)
> b8_10           byte   %2.0f                  Current age of child
> b9_10           byte   %1.0f       b9_10      Who child lives with
> b10_10          byte   %1.0f       b10_10     Completeness of information
> b11_10          byte   %3.0f                  Preceding birth interval
> b12_10          int    %3.0f                  Succeeding birth interval
> b13_10          byte   %1.0f       b13_10     Flag for age at death
> b14_10          byte   %1.0f       b14_10     Birth interval >= 4 years -
NA
> b15_10          byte   %1.0f       b15_10     Live birth between births -
NA
>
>
> . global varx "bidx_ bord_ b0_ b3_ b4_ b5_ b7_ b11_ "
> . global varx2 "bidx bord b0 b3 b4 b5 b7 b11"
> . reshape long $varx, i(wid) j(j 01 02 03 04 05 06 07 08 09 10)
> . foreach X of global varx2 {
>      rename `X'_  `X'
>      }
> . drop *_*
> . save "C:\Documents and Settings\Desktop\childrendata.dta", replace
> . count
> 80950
>
> . su
>
>         bidx |       287          10           0         10         10
>         bord |       287    1.919861    1.166485          1          6
> -------------+--------------------------------------------------------
>           b0 |       287    .0836237    .3739462          0          2
>           b3 |       287    850.6167    53.78004        697        975
>           b4 |       287    1.508711    .5007973          1          2
>           b5 |       287    .6689895    .4713988          0          1
>           b7 |        95    35.71579    65.85294          0        312
>         b11 |       143    25.37063    10.92141         10         63
>
>
>
> My problem is about the huge difference between 80950 and 287.
>
> What is wrong with my program ?
>
> Best regards.
>
> Amadou.
>
>
>
>
>
>
>                       "Wallace, John"
>                       <John_Wallace@affymetrix.
To:  "'[email protected]'"
>                       com>
<[email protected]>
>                       Sent by:                         cc:
>                       owner-statalist@hsphsun2.        Subject:  st: RE:
Reshape problem.
>                       harvard.edu
>
>
>                       11/14/2003 08:15 PM
>                       Please respond to
>                       statalist
>
>
>
>
>
>
>
>
> One of the things that reshape can do is "compress" the number of
> observations by increasing the number of variables.  It all depends on the
> exact implemenation you're using.
>
> For example, if I have a list of 100 observations, consisting of 20
> individuals with 5 measurements, I could reshape it into 20 observations
> with 5 variables, and still have the same overall information represented
in
> the data set.  In this case, the i factor of the reshape would be
> individual, the j factor would be variable, and the x factor would be
> measurement.
>
> It would be easier to help you with more specific descriptions of your
data
> structure, and the syntax you used to reshape.
>
> Sincerely
> John Wallace
> Research Associate
> Affymetrix, Inc
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> Sent: Friday, November 14, 2003 5:11 PM
> To: [email protected]
> Subject: st: Reshape problem.
>
> Hi,
>
> I am trying to reshape a dataset.
> The original dataset contains 5500 individuals.
> But when I reshape it, (after having carefully
> read the manual), my new dataset only contains 20
> observations.
>
> There is very few missing observations in the original dataset.
>
> What is wrong with the command?
>
> *
> *   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/
>
>
>
>
>
>
> *
> *   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/
>

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index