The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Fertility » Indonesia vcal calendar data
Re: Indonesia vcal calendar data [message #18181 is a reply to message #3648] Mon, 07 October 2019 18:48 Go to previous messageGo to previous message
zelalemth is currently offline  zelalemth
Messages: 4
Registered: August 2018
Location: United States
Member
I was trying to convert the STATA code to SAS but I was not getting same results as in the tables. I am not sure if I converted the code correctly.
I appreciate your assistance in advance.

data data1;
set c.RWIR70FL;

* Calculate still births in the last 5 years;
stillbirths = 0;
births = 0;
nlbirths = 0;

* Set length of calendar to use;
callen = v018 + 59;
* If calendar is aligned right (as in original dataset), use the following;
beg = v018;
end = callen;

/* If calendar is aligned left (as it appears to be), use the following;
beg = 1;
end = 60;*/

* Loop through calendar summing births, non-live pregnancies and stillbirths
forvalues i = 1/80 {;
do i = 1 to 80;
* Restrict to 60 months preceding survey;
if i >= beg & i <= end & substr(vcal_1,i,1) = "B" then births = births+1;

if i >= beg & i <= end & substr(vcal_1,i,1) = "T" then nlbirths = nlbirths+1;

if i >= beg & i <= end & substr(vcal_1,i,7) = "TPPPPPP" then stillbirths = stillbirths+1;

end;

* total pregnancies in last 5 years;
totpreg5 = births+nlbirths;
* total pregnancies of 7+ months in last 5 years (all live births, plus the stillbirths);
totpreg7m = births+stillbirths;

* Create weight variable;
sweight = v005/1000000;



run;


* Set up parameters for complex samples and produce number of stillbirths;
proc surveyfreq data = data1;
cluster v021;
strata v023;
weight sweight;
tables stillbirths totpreg7m totpreg5;

run;

[Updated on: Mon, 07 October 2019 18:50]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: B11 is actually missing or it represent first birth?
Next Topic: last birth
Goto Forum:
  


Current Time: Thu Jul 2 17:05:23 Eastern Daylight Time 2020