Home » Dissemination and Capacity Strengthening » Application Programming Interface (API) » Record Limits
Re: Record Limits [message #9591 is a reply to message #9570] |
Tue, 19 April 2016 15:17 |
nchakraborty
Messages: 6 Registered: April 2016
|
Member |
|
|
Thank you, Trevor.
The STATA loop I wrote is shared below for others. The list of indicators requested has been truncated.
/*API allows 3000 records at a time for a user, but you can select subsequent pages of records
The code below loops through requests for additional pages of records, without knowing
how many pages there will be. It then appends all of the pages, each saved as a dataset
into 1 file */
local i=1
while `i'<1000 {
clear
gen str9 surveyid=""
gen str30 group=""
gen str30 grouplabel=""
gen str30 indicatorID=""
gen str10 value=""
gen str30 country=""
#delimit;
insheetjson surveyid country indicatorID group grouplabel value
using " http://api.dhsprogram.com/rest/dhs/data?breakdown=all&su rveyYear=2010,2011,2012,2013,2014&indicatorIDs=FP_CUSM_W _MOD,FP_CUSA_W_MOD,FP_CUSU_W_MOD&perpage=3000&page=` i'",
table(Data) col(SurveyId CountryName IndicatorId CharacteristicCategory CharacteristicLabel Value);
#delimit cr
save "page`i'.dta", replace
if _N<3000 {
exit
}
else {
local i=`i'+1
}
}
while `i'>1 {
local i=`i'-1
append using "page`i'.dta"
}
|
|
|
Goto Forum:
Current Time: Thu Apr 25 05:25:40 Coordinated Universal Time 2024
|