The DHS Program User Forum
Discussions regarding The DHS Program data and results
Home » Topics » Reproductive Health » Pregnancy History
Re: Pregnancy History [message #10055 is a reply to message #10046] Mon, 20 June 2016 10:29 Go to previous messageGo to previous message
Trevor-DHS is currently offline  Trevor-DHS
Messages: 805
Registered: January 2013
Senior Member
You are misunderstanding the Stata code which converts the dataset from a wide format with multiple pregnancies per woman to a long format where each record is a pregnancy.

Below is the equivalent code in SPSS:

* Open data file.
GET FILE='PKIR61FL.SAV'.

* Reformat pregnancy history from variables to cases.
VARSTOCASES
  /MAKE IDX97 FROM IDX97$01 IDX97$02 IDX97$03 IDX97$04 IDX97$05 IDX97$06 IDX97$07 IDX97$08 IDX97$09 
    IDX97$10 IDX97$11 IDX97$12 IDX97$13 IDX97$14 IDX97$15 IDX97$16 IDX97$17 IDX97$18 IDX97$19 IDX97$20 IDX97$21
  /MAKE ORD97 FROM ORD97$01 ORD97$02 ORD97$03 ORD97$04 ORD97$05 ORD97$06 ORD97$07 ORD97$08 ORD97$09 
    ORD97$10 ORD97$11 ORD97$12 ORD97$13 ORD97$14 ORD97$15 ORD97$16 ORD97$17 ORD97$18 ORD97$19 ORD97$20 ORD97$21
  /MAKE S215 FROM S215$01 S215$02 S215$03 S215$04 S215$05 S215$06 S215$07 S215$08 S215$09 S215$10 
    S215$11 S215$12 S215$13 S215$14 S215$15 S215$16 S215$17 S215$18 S215$19 S215$20 S215$21
  /MAKE S216 FROM S216$01 S216$02 S216$03 S216$04 S216$05 S216$06 S216$07 S216$08 S216$09 S216$10 
    S216$11 S216$12 S216$13 S216$14 S216$15 S216$16 S216$17 S216$18 S216$19 S216$20 S216$21
  /MAKE S217 FROM S217$01 S217$02 S217$03 S217$04 S217$05 S217$06 S217$07 S217$08 S217$09 S217$10 
    S217$11 S217$12 S217$13 S217$14 S217$15 S217$16 S217$17 S217$18 S217$19 S217$20 S217$21
  /MAKE S219 FROM S219$01 S219$02 S219$03 S219$04 S219$05 S219$06 S219$07 S219$08 S219$09 S219$10 
    S219$11 S219$12 S219$13 S219$14 S219$15 S219$16 S219$17 S219$18 S219$19 S219$20 S219$21
  /MAKE S220M FROM S220M$01 S220M$02 S220M$03 S220M$04 S220M$05 S220M$06 S220M$07 S220M$08 S220M$09 
    S220M$10 S220M$11 S220M$12 S220M$13 S220M$14 S220M$15 S220M$16 S220M$17 S220M$18 S220M$19 S220M$20 S220M$21
  /MAKE S220Y FROM S220Y$01 S220Y$02 S220Y$03 S220Y$04 S220Y$05 S220Y$06 S220Y$07 S220Y$08 S220Y$09 
    S220Y$10 S220Y$11 S220Y$12 S220Y$13 S220Y$14 S220Y$15 S220Y$16 S220Y$17 S220Y$18 S220Y$19 S220Y$20 S220Y$21
  /MAKE S221 FROM S221$01 S221$02 S221$03 S221$04 S221$05 S221$06 S221$07 S221$08 S221$09 S221$10 
    S221$11 S221$12 S221$13 S221$14 S221$15 S221$16 S221$17 S221$18 S221$19 S221$20 S221$21
  /MAKE S222 FROM S222$01 S222$02 S222$03 S222$04 S222$05 S222$06 S222$07 S222$08 S222$09 S222$10 
    S222$11 S222$12 S222$13 S222$14 S222$15 S222$16 S222$17 S222$18 S222$19 S222$20 S222$21
  /MAKE S223 FROM S223$01 S223$02 S223$03 S223$04 S223$05 S223$06 S223$07 S223$08 S223$09 S223$10 
    S223$11 S223$12 S223$13 S223$14 S223$15 S223$16 S223$17 S223$18 S223$19 S223$20 S223$21
  /MAKE S224 FROM S224$01 S224$02 S224$03 S224$04 S224$05 S224$06 S224$07 S224$08 S224$09 S224$10 
    S224$11 S224$12 S224$13 S224$14 S224$15 S224$16 S224$17 S224$18 S224$19 S224$20 S224$21
  /MAKE S225U FROM S225U$01 S225U$02 S225U$03 S225U$04 S225U$05 S225U$06 S225U$07 S225U$08 S225U$09 
    S225U$10 S225U$11 S225U$12 S225U$13 S225U$14 S225U$15 S225U$16 S225U$17 S225U$18 S225U$19 S225U$20 S225U$21
  /MAKE S225N FROM S225N$01 S225N$02 S225N$03 S225N$04 S225N$05 S225N$06 S225N$07 S225N$08 S225N$09 
    S225N$10 S225N$11 S225N$12 S225N$13 S225N$14 S225N$15 S225N$16 S225N$17 S225N$18 S225N$19 S225N$20 S225N$21
  /MAKE S226M FROM S226M$01 S226M$02 S226M$03 S226M$04 S226M$05 S226M$06 S226M$07 S226M$08 S226M$09 
    S226M$10 S226M$11 S226M$12 S226M$13 S226M$14 S226M$15 S226M$16 S226M$17 S226M$18 S226M$19 S226M$20 S226M$21
  /MAKE S226Y FROM S226Y$01 S226Y$02 S226Y$03 S226Y$04 S226Y$05 S226Y$06 S226Y$07 S226Y$08 S226Y$09 
    S226Y$10 S226Y$11 S226Y$12 S226Y$13 S226Y$14 S226Y$15 S226Y$16 S226Y$17 S226Y$18 S226Y$19 S226Y$20 S226Y$21
  /MAKE S227 FROM S227$01 S227$02 S227$03 S227$04 S227$05 S227$06 S227$07 S227$08 S227$09 S227$10 
    S227$11 S227$12 S227$13 S227$14 S227$15 S227$16 S227$17 S227$18 S227$19 S227$20 S227$21
  /MAKE S228 FROM S228$01 S228$02 S228$03 S228$04 S228$05 S228$06 S228$07 S228$08 S228$09 S228$10 
    S228$11 S228$12 S228$13 S228$14 S228$15 S228$16 S228$17 S228$18 S228$19 S228$20 S228$21
  /MAKE S229 FROM S229$01 S229$02 S229$03 S229$04 S229$05 S229$06 S229$07 S229$08 S229$09 S229$10 
    S229$11 S229$12 S229$13 S229$14 S229$15 S229$16 S229$17 S229$18 S229$19 S229$20 S229$21
  /MAKE S220C FROM S220C$01 S220C$02 S220C$03 S220C$04 S220C$05 S220C$06 S220C$07 S220C$08 S220C$09 S220C$10 
    S220C$11 S220C$12 S220C$13 S220C$14 S220C$15 S220C$16 S220C$17 S220C$18 S220C$19 S220C$20 S220C$21
  /MAKE S220F FROM S220F$01 S220F$02 S220F$03 S220F$04 S220F$05 S220F$06 S220F$07 S220F$08 S220F$09 S220F$10 
    S220F$11 S220F$12 S220F$13 S220F$14 S220F$15 S220F$16 S220F$17 S220F$18 S220F$19 S220F$20 S220F$21
  /MAKE S225C FROM S225C$01 S225C$02 S225C$03 S225C$04 S225C$05 S225C$06 S225C$07 S225C$08 S225C$09 S225C$10 
    S225C$11 S225C$12 S225C$13 S225C$14 S225C$15 S225C$16 S225C$17 S225C$18 S225C$19 S225C$20 S225C$21
  /MAKE S225F FROM S225F$01 S225F$02 S225F$03 S225F$04 S225F$05 S225F$06 S225F$07 S225F$08 S225F$09 S225F$10 
    S225F$11 S225F$12 S225F$13 S225F$14 S225F$15 S225F$16 S225F$17 S225F$18 S225F$19 S225F$20 S225F$21
  /INDEX=Index1(21) 
  /KEEP=CASEID V001 V002 V003 V005 V008 V013 V024 V025
  /NULL=DROP.

* Create outcome variable.
IF (S216 = 1 OR S217 = 1) outcome = 1.
IF (SYSMIS(OUTCOME) AND S216 = 2) outcome = 2.
IF (SYSMIS(OUTCOME) AND S228 = 1) outcome = 3.
IF (SYSMIS(OUTCOME) AND (MISSING(S228) OR S228 <> 1)) outcome = 4.

VARIABLE LABELS outcome "Pregnancy outcome".
VALUE LABELS outcome 1 "Live birth" 2 "Stillbirth" 3 "Abortion" 4 "Miscarriage".
FORMATS outcome (f1.0).

FREQUENCIES VARIABLES=outcome.

 
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
Read Message
Previous Topic: Manual calculation of fertility
Next Topic: TIMELY & COMPLETION ANTENATAL
Goto Forum:
  


Current Time: Sun Dec 29 10:05:30 Coordinated Universal Time 2024