|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: many children per mother to one record per child DHS data rewriteSAS do file
From |
Daniel Wilde <[email protected]> |
To |
[email protected] |
Subject |
st: many children per mother to one record per child DHS data rewriteSAS do file |
Date |
Tue, 02 Oct 2007 14:28:15 +0100 |
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/