diff --git a/pcn.ado b/pcn.ado index f2555db..e91e6d4 100644 --- a/pcn.ado +++ b/pcn.ado @@ -31,6 +31,7 @@ pause /// vermast(string) /// veralt(string) /// * /// +qui /// ] version 14 @@ -80,6 +81,12 @@ qui { if ("`maindir'" == "") local maindir "`drive':/`root'" + if ("`qui'" == "") { + local nq "noi" + } + else { + local nq "qui" + } //------------ Download functions @@ -89,7 +96,7 @@ qui { noi disp as text "Options available to download" local i = 0 - noi disp _n "select survey to load" _request(_survey) + noi disp _n "select survey to load" foreach db of local dldb { local ++i noi disp `" `i' {c |} {stata `db'}"' @@ -117,7 +124,7 @@ qui { if regexm("`subcmd'", "download[ ]+gpwg") { - noi pcn_download_gpwg, countries(`countries') years(`years') /* + `nq' pcn_download_gpwg, countries(`countries') years(`years') /* */ maindir("`maindir'") `pause' `options' return add exit @@ -129,11 +136,11 @@ qui { if regexm("`subcmd'", "primus[ ]+approved") { if regexm("`options'", "down\(.*\)") { - noi pcn_primus_download, countries(`countries') years(`years') /* + `nq' pcn_primus_download, countries(`countries') years(`years') /* */ status(approved) `pause' `options' } else if regexm("`options'", "load\(.*\)"){ - noi pcn_primus_load, s(approved) `pause' `options' + `nq' pcn_primus_load, s(approved) `pause' `options' } else err @@ -143,11 +150,11 @@ qui { if regexm("`subcmd'", "primus[ ]+pending") { if regexm("`options'", "down\(.*\)") { - noi pcn_primus_download, countries(`countries') years(`years') /* + `nq' pcn_primus_download, countries(`countries') years(`years') /* */ status(pending) `pause' `options' } else if regexm("`options'", "load\(.*\)"){ - noi pcn_primus_load, s(pending) `pause' `options' + `nq' pcn_primus_load, s(pending) `pause' `options' } else err @@ -160,7 +167,7 @@ qui { //======================================================== if regexm("`subcmd'", "download[ ]+wrk") { local maindir "p:\01.PovcalNet\03.QA\02.PRIMUS\pending" - noi pcn_download_wrk, countries(`countries') years(`years') /* + `nq' pcn_download_wrk, countries(`countries') years(`years') /* */ `pause' `options' maindir("`maindir'") return add exit @@ -172,7 +179,7 @@ qui { if ("`subcmd'" == "load" | "`subcmd'" == "load[ ]+gpwg") { - noi pcn_load, country(`countries') year(`years') type(`type') /* + `nq' pcn_load, country(`countries') year(`years') type(`type') /* */ maindir("`maindir'") vermast(`vermast') veralt(`veralt') /* */ `pause' `options' return add @@ -186,7 +193,7 @@ qui { local maindir "p:\01.PovcalNet\03.QA\02.PRIMUS\pending" - noi pcn_load_wrk, country(`countries') year(`years') /* + `nq' pcn_load_wrk, country(`countries') year(`years') /* */ maindir("`maindir'") vermast(`vermast') /* */ `pause' `clear' `options' return add @@ -200,7 +207,7 @@ qui { local maindir "p:\01.PovcalNet\03.QA\02.PRIMUS\pending" - noi pcn_load_estimates, maindir("`maindir'") /* + `nq' pcn_load_estimates, maindir("`maindir'") /* */ `pause' `clear' `options' return add exit @@ -213,7 +220,7 @@ qui { if ("`subcmd'" == "create") { - noi pcn_create, countries(`countries') years(`years') type(`type') /* + `nq' pcn_create, countries(`countries') years(`years') type(`type') /* */ maindir("`maindir'") vermast(`vermast') veralt(`veralt') /* */ `pause' `options' return add @@ -227,7 +234,7 @@ qui { if inlist(lower("`subcmd'"), "group", "groupdata", "gd", "groupd") { - noi pcn_groupdata, countries(`countries') years(`years') type(`type') /* + `nq' pcn_groupdata, country(`countries') years(`years') type(`type') /* */ vermast(`vermast') veralt(`veralt') /* */ `pause' `options' return add @@ -243,7 +250,7 @@ qui { error } - noi pcn_update_cpi, `pause' `options' + `nq' pcn_update_cpi, `pause' `options' return add exit } @@ -253,7 +260,7 @@ qui { //======================================================== if regexm("`subcmd'", "load[ ]+cpi") { - noi pcn_load_cpi, `pause' `options' + `nq' pcn_load_cpi, `pause' `options' return add exit } @@ -269,11 +276,11 @@ qui { error } - noi pcn_master_update, `pause' `options' + `nq' pcn_master_update, `pause' `options' return add } if regexm("`options'", "load\(.*\)") { - noi pcn_master_load, `pause' `options' + `nq' pcn_master_load, `pause' `options' `qui' return add } exit @@ -286,7 +293,7 @@ qui { if ("`subcmd'" == "test") { - noi pcn_test + `nq' pcn_test exit } diff --git a/pcn_create.ado b/pcn_create.ado index c406cf9..afce903 100644 --- a/pcn_create.ado +++ b/pcn_create.ado @@ -56,7 +56,7 @@ local user=c(username) qui { pcn_primus_query, countries(`countries') years(`years') /// - `pause' vermast("`vermast'") veralt("`veralt'") + `pause' vermast("`vermast'") veralt("`veralt'") gpwg local varlist = "`r(varlist)'" local n = _N @@ -140,60 +140,160 @@ qui { * monthly data replace welfare=welfare/12 - * keep weight and welfare - keep weight welfare - sort welfare + keep weight welfare urban - * drop missing values - drop if welfare < 0 | welfare == . - drop if weight <= 0 | weight == . + * special treatment for IDN and IND + if inlist("`country'", "IND", "IDN") { + preserve + keep if urban==0 + tempfile rfile + char _dta[cov] "R" + save `rfile' - order weight welfare + restore, preserve - //======================================================== - // Check if data is the same as the previous one and save. - //======================================================== + keep if urban==1 + char _dta[cov] "U" + tempfile ufile + save `ufile' - cap datasignature confirm using "`surdir'/`survid'/Data/`survid'_PCN" - local dsrc = _rc - if (`dsrc' == 9) { - cap mkdir "`surdir'/`survid'/Data/_vintage" - preserve // I cannot use copy because I need the pcn_datetime char + restore - use "`surdir'/`survid'/Data/`survid'_PCN.dta", clear - save "`surdir'/`survid'/Data/_vintage/`survid'_PCN_`:char _dta[creationdate]'", replace + + // Loading PPPs, population data and CPI data + preserve + + // PPPs + pcn master, load(ppp) qui + keep if countrycode == "`country'" & lower(coveragetype) != "national" + gen urban = lower(coveragetype) == "urban" + keep urban ppp2011 + tempfile ppp + save `ppp' + + // Population + pcn master, load(population) qui + keep if countrycode=="`country'" & lower(coveragetype) != "national" & year==`year' + gen urban = lower(coveragetype) == "urban" + keep urban population + tempfile pop + save `pop' + + // CPI + pcn master, load(cpi) qui + keep if countrycode=="`country'" & lower(coveragetype) != "national" & year==`year' + gen urban = lower(coveragetype) == "urban" + keep urban cpi + tempfile cpi + save `cpi' restore + + // Merge with raw data + merge m:1 urban using `ppp', nogen + merge m:1 urban using `pop', nogen + merge m:1 urban using `cpi', nogen + + // Create welfare in daily PPP terms + replace welfare = welfare*12/365/cpi/ppp + + // Rescaling weights + forvalues x = 0/1 { + sum weight if urban==`x' + replace weight = weight*pop/`r(sum)'*10^6 if urban==`x' + } + + label var welfare "Welfare in 2011 USD PPP per day" + + char _dta[cov] "N" + tempfile wfile + save `wfile' + + + local cfiles "`rfile' `ufile' `wfile'" + } // end of special cases + else { + tempfile wfile + char _dta[cov] "" + save `wfile' + local cfiles "`wfile'" } - if (`dsrc' != 0) { - cap datasignature set, reset /* - */ saving("`surdir'/`survid'/Data/`survid'_PCN", replace) - char _dta[filename] = "`filename'" - char _dta[survin] = "`survin'" - char _dta[survid] = "`survid'" - char _dta[surdir] = "`surdir'" - char _dta[creationdate] = "`date_time'" + foreach file of local cfiles { - //------------Uncollapsed data - save "`surdir'/`survid'/Data/`survid'_PCN.dta", `replace' - export delimited using "`surdir'/`survid'/Data/`survid'_PCN.txt", /// - novarnames nolabel delimiter(tab) `replace' + use `file', clear + local cc: char _dta[cov] // country coverage + if ("`cc'" == "") { + local cc "N" + local cov "" + } + else { + local cov "-`cc'" + } + * keep weight and welfare + keep weight welfare + sort welfare - //------------ collapse data - collapse (sum) weight, by(welfare) + * drop missing values + drop if welfare < 0 | welfare == . + drop if weight <= 0 | weight == . - save "`surdir'/`survid'/Data/`survid'_PCNc.dta", `replace' + order weight welfare - export delimited using "`surdir'/`survid'/Data/`survid'_PCNc.txt", /// - novarnames nolabel delimiter(tab) `replace' - noi _dots `i' 0 - } - else { - noi _dots `i' -1 - continue - } + //======================================================== + // Check if data is the same as the previous one and save. + //======================================================== + + cap datasignature confirm using "`surdir'/`survid'/Data/`survid'_PCN`cov'" + local dsrc = _rc + if (`dsrc' == 9) { + cap mkdir "`surdir'/`survid'/Data/_vintage" + preserve // I cannot use copy because I need the pcn_datetime char + + use "`surdir'/`survid'/Data/`survid'_PCN`cov'.dta", clear + save "`surdir'/`survid'/Data/_vintage/`survid'_PCN`cov'_`:char _dta[creationdate]'", replace + + restore + } + if (`dsrc' != 0 | "`replace'" != "") { + cap datasignature set, reset /* + */ saving("`surdir'/`survid'/Data/`survid'_PCN`cov'", replace) + + char _dta[filename] "`filename'" + char _dta[survin] "`survin'" + char _dta[survid] "`survid'" + char _dta[surdir] "`surdir'" + char _dta[creationdate] "`date_time'" + char _dta[survey_coverage] "`cc'" + + // Special case for IDN 2018 (should be deleted later) + if ("`country'" == "IDN") { + char _dta[welfaretype] "CONS" + char _dta[weighttype] "aw" + } + + + //------------Uncollapsed data + save "`surdir'/`survid'/Data/`survid'_PCN`cov'.dta", `replace' + export delimited using "`surdir'/`survid'/Data/`survid'_PCN`cov'.txt", /// + novarnames nolabel delimiter(tab) `replace' + + + //------------ collapse data + collapse (sum) weight, by(welfare) + + save "`surdir'/`survid'/Data/`survid'_PCNc`cov'.dta", `replace' + + export delimited using "`surdir'/`survid'/Data/`survid'_PCNc`cov'.txt", /// + novarnames nolabel delimiter(tab) `replace' + noi _dots `i' 0 + } + else { + noi _dots `i' -1 + continue + } + } // end of files loop * mata: P = pcn_info(P) diff --git a/pcn_download_gpwg.ado b/pcn_download_gpwg.ado index 574232c..b6da3a2 100644 --- a/pcn_download_gpwg.ado +++ b/pcn_download_gpwg.ado @@ -47,7 +47,9 @@ local user=c(username) ==================================================*/ qui { pcn_primus_query, countries(`countries') years(`years') /// - `pause' + `pause' gpwg + + pause after primus query local varlist = "`r(varlist)'" local n = _N diff --git a/pcn_groupdata.ado b/pcn_groupdata.ado index 74782d0..6d9bbdd 100644 --- a/pcn_groupdata.ado +++ b/pcn_groupdata.ado @@ -18,8 +18,8 @@ Output: ==================================================*/ program define pcn_groupdata, rclass syntax [anything(name=subcmd id="subcommand")], /// -[ /// -COUNtries(string) /// +COUNtry(string) /// +[ /// Years(numlist) /// maindir(string) /// type(string) /// @@ -27,7 +27,7 @@ clear /// pause /// vermast(string) /// veralt(string) /// -replace /// +replace /// * /// ] version 14 @@ -37,6 +37,11 @@ if ("`pause'" == "pause") pause on else pause off +if (wordcount("`country'") != 1) { + noi disp in red "{it: country()} must have only one countrycode" + error +} + //------------set up if ("`maindir'" == "") cd "p:\01.PovcalNet\03.QA\01.GroupData" else cd "`maindir'" @@ -51,43 +56,26 @@ local dirsep = c(dirsep) local vintage: disp %tdD-m-CY date("`c(current_date)'", "DMY") - -*------------------ Initial Parameters ------------------ -local mfiles: dir "../../00.Master/02.vintage/" files "Master_*.xlsx", respect -local vcnumbers: subinstr local mfiles "Master_" "", all -local vcnumbers: subinstr local vcnumbers ".xlsx" "", all -local vcnumbers: list sort vcnumbers - -mata: VC = strtoreal(tokens(`"`vcnumbers'"')); /* -*/ st_local("maxvc", strofreal(max(VC), "%15.0f")) - -* exDate = Format(Now(), "yyyymmddHhNnSs") // VBA name - - //------------load data -import excel "raw_GroupData.xlsx", sheet("raw_GroupData") firstrow clear +import excel "04.formatted/`country'/`country'_raw_GroupData.xlsx", /* + */ sheet("raw_GroupData") firstrow clear tostring survey, replace // in case survey is unknown gen id = countrycode + " " + strofreal(year) + " " + /* -*/ strofreal(coverage) + " " + datatype + " 0" + /* -*/ strofreal(formattype) + " " + survey +*/ coverage + " " + datatype + " 0" + /* +*/ strofreal(formattype) + " " + survey //------------saving data vintages levelsof id, local(ids) qui foreach id of local ids { - local cc: word 1 of `id' - local yr: word 2 of `id' - local cg: word 3 of `id' - local dt: word 4 of `id' - local ft: word 5 of `id' - local sy: word 6 of `id' - - if (`cg' == 1) local cov = "R" - else if (`cg' == 2) local cov = "U" - else if (`cg' == 3) local cov = "N" - else local cov = "A" + local cc: word 1 of `id' + local yr: word 2 of `id' + local cov: word 3 of `id' + local dt: word 4 of `id' + local ft: word 5 of `id' + local sy: word 6 of `id' local l2y = substr("`yr'", 3,.) @@ -169,16 +157,17 @@ qui foreach id of local ids { local datetimeHRF: disp %tcDDmonCCYY_HH:MM:SS `datetime' local datetimeHRF = trim("`datetimeHRF'") - char _dta[filename] `fileid'_GROUP-`cov'.dta - char _dta[id] `fileid' - char _dta[datatype] `dt' - char _dta[countrycode] `cc' - char _dta[year] `yr' - char _dta[coverage] `cov' - char _dta[groupdata] 1 - char _dta[formattype] `ft' - char _dta[datetime] `datetime' - char _dta[datetimeHRF] `datetimeHRF' + char _dta[filename] `fileid'_GROUP-`cov'.dta + char _dta[id] `fileid' + char _dta[welfaretype] `dt' + char _dta[weighttype] "PW" + char _dta[countrycode] `cc' + char _dta[year] `yr' + char _dta[survey_coverage] `cov' + char _dta[groupdata] 1 + char _dta[formattype] `ft' + char _dta[datetime] `datetime' + char _dta[datetimeHRF] `datetimeHRF' cap mkdir "`sydir'/_vintage" save "`sydir'/_vintage/`signature'_`datetime'.dta", replace @@ -198,24 +187,19 @@ qui foreach id of local ids { *get the mean sum welfare [w = welfare], meanonly - local `cc'`yr'`cg'm = r(mean) + local `cc'`yr'`cov'm = r(mean) restore } //------------ Check both files are in the most recent folder qui foreach id of local ids { - local cc: word 1 of `id' - local yr: word 2 of `id' - local cg: word 3 of `id' - local dt: word 4 of `id' - local ft: word 5 of `id' - local sy: word 6 of `id' - - if (`cg' == 1) local cov = "R" - else if (`cg' == 2) local cov = "U" - else if (`cg' == 3) local cov = "N" - else local cov = "A" + local cc: word 1 of `id' + local yr: word 2 of `id' + local cov: word 3 of `id' + local dt: word 4 of `id' + local ft: word 5 of `id' + local sy: word 6 of `id' local l2y = substr("`yr'", 3,.) diff --git a/pcn_master_load.ado b/pcn_master_load.ado index 2774213..bc682ae 100644 --- a/pcn_master_load.ado +++ b/pcn_master_load.ado @@ -21,6 +21,7 @@ syntax [anything], load(string) /// version(string) /// pause /// shape(string) /// +qui /// ] version 14 @@ -81,11 +82,13 @@ qui { local dispdate: disp %tcDDmonCCYY_HH:MM:SS `svc' local dispdate = trim("`dispdate'") - noi disp `" `i' {c |} {stata `vc':`dispdate'}"' + local scode "pcn master, load(`load') version(`vc')" + noi disp `" `i' {c |} {stata `scode':`dispdate'}"' } - noi disp _n "select vintage control date from the list above" _request(_vcnumber) + noi disp _n "select vintage control date from the list above" + exit } else if inlist(lower("`version'"), "maxvc", "max", "") { local vcnumber = `maxvc' @@ -113,9 +116,10 @@ qui { local svc = clock("`vcnumber'", "YMDhms") // stata readable form local dispdate: disp %tcDDmonCCYY_HH:MM:SS `svc' - noi disp in y "File:" _col(8) "{stata br:Master_`vcnumber'.xlsx} " /* - */ in y "will be loaded. " _n "Date: " _col(8) in w "`dispdate'" - + if ("`qui'" == "") { + noi disp in y "File:" _col(8) "{stata br:Master_`vcnumber'.xlsx} " /* + */ in y "will be loaded. " _n "Date: " _col(8) in w "`dispdate'" + } //======================================================== // Pick sheet @@ -149,36 +153,36 @@ qui { // CPI //======================================================== if (lower("`load'") == "cpi") { - import excel using "`mastervin'/Master_`vcnumber'.xlsx", /* - */ sheet("CPI") clear firstrow case(lower) - - missings dropvars, force - missings dropobs, force - - _label2name - - if ("`shape'" == "long") { - reshape long y, i(countrycode coverqge) j(year) - rename y cpi - drop if cpi == . - - * fix mismatches between the two dataset - rename coverqge coveragetype - clonevar data_coverage = coveragetype - - replace data_coverage = "Urban" if countrycode == "ARG" - replace data_coverage = "Rural" if countrycode == "ETH" & year == 1981 - replace data_coverage = "Urban" if countrycode == "BOL" & year == 1992 - replace data_coverage = "Urban" if countrycode == "ECU" & year == 1995 - replace data_coverage = "Urban" if countrycode == "FSM" & year == 2000 - replace data_coverage = "Urban" if countrycode == "HND" & year == 1986 - replace data_coverage = "Urban" if countrycode == "COL" & inrange(year, 1980,1991) - replace data_coverage = "Urban" if countrycode == "URY" & inrange(year, 1990,2005) - label var year "Year" - label var cpi "CPI" - } - - * if ("`shape'" == "long") rename year cpi_time + import excel using "`mastervin'/Master_`vcnumber'.xlsx", /* + */ sheet("CPI") clear firstrow case(lower) + + missings dropvars, force + missings dropobs, force + + _label2name + + if ("`shape'" == "long") { + reshape long y, i(countrycode coverqge) j(year) + rename y cpi + drop if cpi == . + + * fix mismatches between the two dataset + rename coverqge coveragetype + clonevar data_coverage = coveragetype + + replace data_coverage = "Urban" if countrycode == "ARG" + replace data_coverage = "Rural" if countrycode == "ETH" & year == 1981 + replace data_coverage = "Urban" if countrycode == "BOL" & year == 1992 + replace data_coverage = "Urban" if countrycode == "ECU" & year == 1995 + replace data_coverage = "Urban" if countrycode == "FSM" & year == 2000 + replace data_coverage = "Urban" if countrycode == "HND" & year == 1986 + replace data_coverage = "Urban" if countrycode == "COL" & inrange(year, 1980,1991) + replace data_coverage = "Urban" if countrycode == "URY" & inrange(year, 1990,2005) + label var year "Year" + label var cpi "CPI" + } + + * if ("`shape'" == "long") rename year cpi_time } diff --git a/pcn_master_update.ado b/pcn_master_update.ado index 47f3deb..7a1f88a 100644 --- a/pcn_master_update.ado +++ b/pcn_master_update.ado @@ -20,7 +20,9 @@ syntax [anything], /// update(string) /// [ /// cpivin(string) /// -MAXYear(integer 2018) /// +MAXYear(integer 2018) /// +FORCE /// +pause /// ] version 15 // this is really important @@ -85,9 +87,12 @@ qui { replace cpi2011_unadj = cpi2011 if inlist(code, "IDN", "IND", "CHN") - //------------ vector of available years - sum year, meanonly + + gen yr = year + replace yr = floor(ref_year) if ref_year <. // starting year of the survey + + sum yr, meanonly local ymin = r(min) local ymax = r(max) tempname C @@ -96,30 +101,32 @@ qui { //------------Rename to match Master file especifications rename (cpi2011_unadj code levelnote countryname) (y CountryCode Coverqge CountryName) - keep y CountryCode Coverqge CountryName survname year + keep y CountryCode Coverqge CountryName survname yr + duplicates drop // to adress the case of ETH + preserve - contract CountryCode Coverqge CountryName survname - drop _freq - local csize = `ymax'- `ymin' - expand `csize' - bysort CountryCode Coverqge CountryName survname: egen year = seq() - replace year = year - 1 + `ymin' - tempfile cdata - save `cdata' - restore - - merge 1:1 CountryCode Coverqge CountryName survname year using `cdata', nogen - sort CountryCode year survname - + contract CountryCode Coverqge CountryName survname + drop _freq + local csize = `ymax'- `ymin' + expand `csize' + bysort CountryCode Coverqge CountryName survname: egen yr = seq() + replace yr = yr - 1 + `ymin' + tempfile cdata + save `cdata' + restore + + merge 1:1 CountryCode Coverqge CountryName survname yr using `cdata', nogen + sort CountryCode yr survname + //------------Manual fix for India - sort CountryCode Coverqge survname year - replace y = y[_n-1] if (CountryCode == "IND" & year == 2012) - replace y = 1 if (CountryCode == "IND" & year == 2011) - + sort CountryCode Coverqge survname yr + replace y = y[_n-1] if (CountryCode == "IND" & yr == 2012) + replace y = 1 if (CountryCode == "IND" & yr == 2011) + //------------Re format to export - - reshape wide y, i(CountryCode CountryName Coverqge survname) j(year) + + reshape wide y, i(CountryCode CountryName Coverqge survname) j(yr) collapse (mean) y*, by(CountryCode CountryName Coverqge) // fix if cpi per survey change tempname D @@ -169,7 +176,7 @@ qui { ren ny_gdp_pcap_kd wdi_gdp keep countrycode year wdi_gdp - gen sourcegdp="WDI 2019" + gen sourcegdp="WDI 2020-02" local madison "https://www.rug.nl/ggdc/historicaldevelopment/maddison/data/mpd2018.dta" merge 1:1 countrycode year using "`madison'", nogen @@ -218,9 +225,10 @@ qui { merge 1:1 countrycode coverage year using `sna', replace update rename gdp sp_= - gen special= inlist(_merge, 3, 4, 5) + gen special= inlist(_merge, 2, 3, 4, 5) drop _merge + keep if inrange(year,1960, `maxyear') //======================================================== // Espen's code //======================================================== @@ -264,10 +272,21 @@ qui { replace sourcegdp = "NONE" if new_gdp==. //---- Espen's code ----- End + missings dropobs, force + //------------ Save metadata + local msheet = upper("`update'") + cap datasignature confirm using "`masterdir'/03.metadata/`msheet'" + if (_rc == 0 & "`force'" == "") { + noi disp in g "Sheet `msheet' has not changed since last time. No update will be made." + exit + } - keep if inrange(year,1960, `maxyear') - missings dropobs, force + datasignature set, reset saving("`masterdir'/03.metadata/`msheet'", replace) + save "`masterdir'/03.metadata/_vintage/`msheet'_`date_time'.dta", replace + save "`masterdir'/03.metadata/`msheet'.dta", replace + + //------------ arrange code. keep countrycode coverage year new_gdp preserve datalibweb_inventory, clear @@ -533,6 +552,8 @@ qui { drop series_name col series drop if year > `maxyear' sort country year + + drop if year < 1977 //------------Matrix with years available sum year, meanonly @@ -549,6 +570,8 @@ qui { label var coverage "Coverage" label var country_name "Country Name" label var country "Country Code" + + pause after reshape to wide //------------Matrix with population values tempname D mkmat pop*, matrix(`D') @@ -573,7 +596,7 @@ qui { copy "`mastervin'/`newfile'.xlsx" "`masterdir'/01.current/Master.xlsx", replace local success = 1 - } + } /*================================================== PPP @@ -605,8 +628,8 @@ qui { putexcel save - noi disp in y "sheet(`msheet') in Master data has been update." _n /* - */ "{stata pcn master, load(`msheet'):Load data}" + noi disp in y "sheet(`msheet') in Master data has been update." _n /* + */ "{stata pcn master, load(`msheet'):Load data}" } // end of success } // end of qui diff --git a/pcn_primus_query.ado b/pcn_primus_query.ado index 083887b..65e1e09 100644 --- a/pcn_primus_query.ado +++ b/pcn_primus_query.ado @@ -31,6 +31,7 @@ MODule(string) /// clear /// pause /// status(string) /// +gpwg /// ] version 14 @@ -47,6 +48,21 @@ else pause off if ("`status'" == "") local status "approved" primus query, overalls(`status') +if ("`gpwg'" != "") { + preserve + primus query, overalls(pending) + local pr = `" "PENDING", "REJECTED", "-" "' + keep if !inlist(regional, `pr') & !inlist(decdg, `pr') & !inlist(povcalnet, `pr') + local nobs = _N + tempfile pendingf + save `pendingf', emptyok + restore + if (`nobs' != 0) { + append using `pendingf' + } +} + + * replace those that finish in GPWG and SARMD or something else. replace survey_id = regexs(1)+"GMD" if regexm(survey_id , "(.*)(GPWG.*)$") diff --git a/pcn_savedata.ado b/pcn_savedata.ado index cfbdb0d..48a960f 100644 --- a/pcn_savedata.ado +++ b/pcn_savedata.ado @@ -70,6 +70,12 @@ if (_rc) { // if file does not exist local mod = upper("`try'") local dlwcall = regexr("`dlwcall'", "(module\([a-zA-Z0-9]+\))", "") cap `dlwcall' module(`mod') + if (_rc & "`survey'" == "EU-SILC") { + + local dlwcall = regexr("`dlwcall'", "(veralt\([a-zA-Z0-9]+\))", "") + local dlwcall = regexr("`dlwcall'", "(vermast\([a-zA-Z0-9]+\))", "") + cap `dlwcall' + } } if (_rc) { local dlwnote "Error on datalibweb. File does NOT exist in P drive"