Home » Dissemination and Capacity Strengthening » Application Programming Interface (API) » Generate percent of respondents by background characteristics (Demographics using API)
Generate percent of respondents by background characteristics [message #24245] |
Mon, 28 March 2022 17:29 |
DHSuser_NY
Messages: 9 Registered: November 2019
|
Member |
|
|
Good afternoon,
The attached table was created in StatCompiler showing percent of respondents by background demographics(age,residence,marital and wealth) using the the link below which StatCompiler generates when you share the tables. Because this is a table we run quite frequently for different surveys, using the link was a real time-saver.
https://www.statcompiler.com/en/#cc=GM,LB,RW&ucc=&ic =SV_BACK_W_PCW&scl=10000,9001,9002,9003,3001,3002,6001,6 002,6003,6004,6005,15000,15001,15002,15003,15004,16001,16002 &dt=0&pt=0&ss=1&levelRank=0&si=SV_BACK_W _PCW&sbv= .
I would like to extract the same data using API which I am fairly new to. The following call in Stata only gives me wealth and marital status because I have not been able to identify the needed variables for residence(urban/rural) and 5-year age groups. Does anyone know if this information can be extracted from API?
import delimited using ///
" http://api.dhsprogram.com/rest/dhs/data?surveyYearStart=2006 &surveyYearEnd=2022&breakdown=national&indicator Ids=MA_MSTA_W_NMA,MA_MSTA_W_MAR,MA_MSTA_W_LTG,MA_MSTA_W_DIV, MA_MSTA_W_SEP,MA_MSTA_W_WID,MA_MSTA_W_UNI,MA_MSTA_W_MIS,HC_W IXQ_P_LOW,HC_WIXQ_P_2ND,HC_WIXQ_P_MID,HC_WIXQ_P_4TH,HC_WIXQ_ P_HGH,&selectSurveys=latest&returnfields=surveyId,DH S_CountryCode,CountryName,SurveyYear,SurveyYearLabel,SurveyT ype,FieldworkStart,FieldworkEnd,indicator,IndicatorID,value, shortname&f=csv&apiKey=GUTTMA-130129", clear
Thanks for your help.
[Updated on: Mon, 28 March 2022 17:30] Report message to a moderator
|
|
|
Re: Generate percent of respondents by background characteristics-Resolved [message #24250 is a reply to message #24245] |
Tue, 29 March 2022 13:29 |
DHSuser_NY
Messages: 9 Registered: November 2019
|
Member |
|
|
I was able to figure this out. Sharing Stata code in case it is useful for anyone else. I needed to use the background indicator for percent of women(SV_BACK_W_PCW) and specify breakdown = all. This gave me some categories I don't need like education and region, but I just deleted them in Stata.
* Background characteristics table for most recent surveys 2006-2022.
import delimited using " https://api.dhsprogram.com/rest/dhs/data?surveyYearStart=200 6&surveyYearEnd=2022&breakdown=all&indicatorIds= SV_BACK_W_PCW,&selectSurveys=latest&returnfields=sur veyId,DHS_CountryCode,CountryName,SurveyYear,SurveyYearLabel ,SurveyType,FieldworkStart,FieldworkEnd,indicator,IndicatorI D,value,shortname,characteristiclabel,characteristicid,chara cteristiccategory,&f=csv&apiKey=GUTTMA-130129", clear
Best
|
|
|
Goto Forum:
Current Time: Tue Dec 17 21:25:48 Coordinated Universal Time 2024
|