diff --git a/pcn_groupdata.ado b/pcn_groupdata.ado index 84d105a..23342d9 100644 --- a/pcn_groupdata.ado +++ b/pcn_groupdata.ado @@ -40,87 +40,88 @@ if (wordcount("`country'") != 1) { //------------set up if ("`maindir'" == "") local maindir "//wbntpcifs/povcalnet/01.PovcalNet/01.Vintage_control" - -*------------------ Time and system Parameters ------------ -local date = c(current_date) -local time = c(current_time) -local datetime = clock("`date'`time'", "DMYhms") // number, not date -local user = c(username) -local dirsep = c(dirsep) -local vintage: disp %tdD-m-CY date("`c(current_date)'", "DMY") - - -cwf default -local frame_list "area" -foreach fr of local frame_list { - cap frame drop `fr' - frame create `fr' -} - -foreach year of local years { - - datalibweb, countr(`country') year(`year') t(GMD) mod(GROUP) files clear - - local fileid "`r(surveyid)'" - if regexm("`fileid'", "(.+)_[Vv][0-9]+_M") { - local id = regexs(1) - } - - * get some info - levelsof welfare_type, local(dt) - levelsof gd_type, local(gd_type) +qui { + *------------------ Time and system Parameters ------------ + local date = c(current_date) + local time = c(current_time) + local datetime = clock("`date'`time'", "DMYhms") // number, not date + local user = c(username) + local dirsep = c(dirsep) + local vintage: disp %tdD-m-CY date("`c(current_date)'", "DMY") - sort urban welfare - levelsof urban, loca(areas) - if ("`areas'" == "") { - replace urban = 2 - local areas = 2 + cwf default + local frame_list "area" + foreach fr of local frame_list { + cap frame drop `fr' + frame create `fr' } - foreach area of local areas { + foreach year of local years { - frame copy default area, replace - frame area { - keep if urban == `area' - keep weight welfare - replace welfare = welfare/12 - - * suffix - if (`area' == 0) local cov "R" - else if (`area' == 1) local cov "U" - else local cov "N" - - cap makedir "`maindir'/`country'/`id'/`fileid'/Data" - - - //------------Include Characteristics - - local datetimeHRF: disp %tcDDmonCCYY_HH:MM:SS `datetime' - local datetimeHRF = trim("`datetimeHRF'") - - char _dta[filename] `fileid'_GD-`cov'.dta - char _dta[id] `fileid' - char _dta[welfaretype] `dt' - char _dta[weighttype] "PW" - char _dta[countrycode] `country' - char _dta[year] `year' - char _dta[survey_coverage] `cov' - char _dta[groupdata] 1 - char _dta[datetime] `datetime' - char _dta[datetimeHRF] `datetimeHRF' - char _dta[gdtype] "`gd_type'" - char _dta[datatype] "`dt'" - - save "`maindir'/`country'/`id'/`fileid'/Data/`fileid'_GD-`cov'.dta", `replace' + cap datalibweb, countr(`country') year(`year') t(GMD) mod(GROUP) files clear + + local fileid "`r(surveyid)'" + if regexm("`fileid'", "(.+)_[Vv][0-9]+_M") { + local id = regexs(1) + } + + * get some info + levelsof welfare_type, local(dt) clean + levelsof gd_type, local(gd_type) clean + + sort urban welfare + levelsof urban, loca(areas) + + if ("`areas'" == "") { + replace urban = 2 + local areas = 2 + } + + foreach area of local areas { + frame copy default area, replace + frame area { + keep if urban == `area' + keep weight welfare + replace welfare = welfare/12 + + * suffix + if (`area' == 0) local cov "R" + else if (`area' == 1) local cov "U" + else local cov "N" + + makedir "`maindir'/`country'/`id'/`fileid'/Data" + + //------------Include Characteristics + + local datetimeHRF: disp %tcDDmonCCYY_HH:MM:SS `datetime' + local datetimeHRF = trim("`datetimeHRF'") + + char _dta[filename] `fileid'_GD-`cov'.dta + char _dta[id] `fileid' + char _dta[welfaretype] `dt' + char _dta[weighttype] PW + char _dta[countrycode] `country' + char _dta[year] `year' + char _dta[survey_coverage] `cov' + char _dta[groupdata] 1 + char _dta[datetime] `datetime' + char _dta[datetimeHRF] `datetimeHRF' + char _dta[gdtype] `gd_type' + char _dta[datatype] `dt' + + save "`maindir'/`country'/`id'/`fileid'/Data/`fileid'_GD-`cov'.dta", `replace' + + + } } - } - + } // end of years loop -}// end of years loop +} + end @@ -130,16 +131,14 @@ end //======================================================== -program define makedir +program define makedir, rclass syntax anything(name=dir id="subcommand") local dir: subinstr local dir "\" "/", all local dir: subinstr local dir "//" "++" // just the first one -disp "`dir'" - local parse "/" -tokenize "`dir'", parse("`parse'") +tokenize `dir', parse("`parse'") local i = 1 diff --git a/pcn_update_price.ado b/pcn_update_price.ado index 5ce045e..029c76d 100644 --- a/pcn_update_price.ado +++ b/pcn_update_price.ado @@ -19,6 +19,7 @@ program define pcn_update_price, rclass syntax [anything], [ /// replace /// cpivin(string) /// +maindir(string) /// ] version 14