Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: many children per mother to one record per child DHS data rewrite SAS do file


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: many children per mother to one record per child DHS data rewrite SAS do file
Date   Tue, 2 Oct 2007 15:35:18 +0200

Maybe -reshape- will solve the problem?
See:
   help reshape
(wide - > long conversion)

Also see the FAQ:
   http://www.stata.com/support/faqs/data/members.html

Best regards, Sergiy

On 10/2/07, Daniel Wilde <[email protected]> wrote:
> I am current working with Demographic Health Survey Data. This data shows
> numerous children for each mother. I want to create a database that has one
> record for each child. I also want to relabel some of the variables, and
> only keep other relevant variables. David Stifel at Cornell was kind enough
> share a do file in SAS that does something very similar to what I want to
> do, but I am having trouble converting this into STATA. The SAS do file is:
>
>
>  array bidx_a{20} bidx_01-bidx_20;
> array bord_a{20} bord_01-bord_20;
> array   b0_a{20}   b0_01-  b0_20;
> array   b3_a{20}   b3_01-  b3_20;
> array   b4_a{20}   b4_01-  b4_20;
> array   b7_a{20}   b7_01-  b7_20;
> array  b10_a{20}  b10_01- b10_20;
>
> do i=1 to 6 ;
>  if bidx_a{i}>0 then do;
>   hcluster = v001;
>   hhnumber = v002;
>   mother   = v003;
>   wgt      = v005;
>   monthint = v006;
>   yearint  = v007;
>   dateint  = v008;
>   mdob     = v011;
>   region   = v101;
>   urban    = v102;
>
>   bidx     = bidx_a{i};
>   bord     = bord_a{i};
>   twin     =   b0_a{i};
>   dob      =   b3_a{i};
>   sex      =   b4_a{i};
>   aged     =   b7_a{i};
>   flag     =  b10_a{i};
>
>   keep caseid hcluster hhnumber mother wgt monthint yearint dateint
>        mdob region urban bidx bord twin dob sex aged;
>  if bidx_a{i}>0 then output;
>   end;
>  end;
> run;
>
> data work1.temp0;
>  set work1.temp0;
>
>  magekdob = (dob - mdob)/12;
>  age = dateint - dob;
>  yob = int(dob/12);
> run;
>
> proc sort; by hcluster hhnumber mother bidx; run;
> proc contents;
> proc means;
>  weight wgt;
>  title "Bangladesh 1996 (DHS) Mortality Data of Kids";
> run;
>
> libname trn1 xport '/home4/ds52/aadata/bd96mort.v5x';  **;
> proc copy in=work1 out=trn1;
>  select temp0;
> run;
>
> endsas;
>
>
> So, can somebody explain, as simply and in as much detail as possible, how
> this can be written as a STATA do file.
>
> *
> *   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