The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Countries » Bangladesh » Calculating the current use of contraceptive by age group
Re: Calculating the current use of contraceptive by age group [message #1668 is a reply to message #1667] Tue, 25 March 2014 15:49 Go to previous messageGo to previous message
Liz-DHS
Messages: 1516
Registered: February 2013
Senior Member
Dear USer,
I am not a programmer, but here is some code in CSPRo that may help in figuring things out.

The row variables are:
V013w age, value labels 1 15-19 2 20-24 3 25-29 4 30-34 5 35-39 6 40-44 7 45-49 8 50-54
(the other row variables in the table definition are other background characteristics which do not display in this particular table)

The Column variables:
useany value label 1 any method
usemod value label 1 any modern method
modmet2 Modern method, value labels 3 Pill 4 IUD 5 Injectables 6 Implants 7 Male condom 1 Femlae sterilization 2 Male sterilization
8 Female condom 9 Diaphragm 10 Foam/Jelly 11 LAM 12 Emergency contraception
usetrad Value label 1 any traditional method
tradmet2 Traditional method, value labels 13 Periodic abstinence 14 Withdrawal 15 Other
nousing Value label 1 not currently using
totnum2 Value labels 0 Total 1 Number of women
************************************************************ ************************************************************ ***************
Table 5.5 Current use of contraception by age

title( "Table 5.5 Current use of contraception by age"," ",
"Percent distribution of currently married women age 15-49 by contraceptive",
"method currently used and age, Bangladesh 2007" )
stub( "Age" );


crosstab float(1) t505 v013w+v102w+v101w+v149w+v218w2+v190w+total
useany+usemod+modmet2+usetrad+tradmet2+nousing+totnum2
exclude(rowzero,colzero,percents,totals,specval)

{ Table 5.5 processing }
jtot = tblcol( t505 );
jmax = jtot - 2;
do j = 0 while j <= jmax by 1
t505[*,j] = t505[*,j] * 100 / t505[*,jtot];
enddo;
t505[*,jmax+1] = tblsum( column t505[*, 0:jmax] );
any = tblcol( t505, useany );
nouse = tblcol( t505, nousing );
mod = tblcol( t505, usemod );
trad = tblcol( t505, usetrad );
{ total using any method }
t505[*, any] = tblsum( column t505[*, mod+1:nouse-1] );
{ total using any modern method }
t505[*, mod] = tblsum( column t505[*, mod+1:trad-1] );
{ total using any traditional or other method }
t505[*,trad] = tblsum( column t505[*,trad+1:nouse-1] );

{ table 5.4, 5.5 }

modmet2 = notappl;
tradmet2 = notappl;
nousing = notappl;
meth = V312;
box meth => method;
0 => 0;
1-3 => meth+2; { 3-Pill, 4-IUD, 5-Injections }
4 => 9; { 9-Diaphragm }
5 => 7; { 7-Male condom }
6-7 => meth-5; { 1-Female ster, 2-Male ster }
8,9 => meth+5; { 13-Periodic abstinence, 14-Withdrawal }
10 => 15; { 15-Other }
11 => 6; { 6-Implants }
13 => 11; { 11-Lactational amenorrhea }
14 => 8; { 8-Female condom }
15 => 10; { 10-Foam/jelly/suppository }
16 => 12; { 12-Emergency contraception }
=> default;
endbox;
if V313 = 0 then { not using }
nousing = 1
elseif V313 = 3 then { using modern }
modmet2 = method;
elseif V313 = 1 | V313 = 2 then { using traditional & others }
tradmet2 = method;
endif;

if marrwom then

xtab( t504, rweight ); { smg: moving here june 7, as we only want to show CM women }

xtab( t505, rweight );

{ smg: this code/table added 8-19-08 }

if modmet2=7 then { using condom }
rowMDG5=1; xtab (tMDG5, rweight);
endif;

if !(method in 0,default,notappl) then { she's using a method }
rowMDG5=2; xtab (tMDG5, rweight);
endif;

endif;
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Child Nutrition data set
Next Topic: looking for appropriate variable
Goto Forum:
  


Current Time: Sun May 12 13:31:06 Coordinated Universal Time 2024