Skip to content

Commit

Permalink
fix makedir function
Browse files Browse the repository at this point in the history
  • Loading branch information
randrescastaneda committed Feb 25, 2022
1 parent 5533b6f commit b412f49
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 75 deletions.
149 changes: 74 additions & 75 deletions pcn_groupdata.ado
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions pcn_update_price.ado
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ program define pcn_update_price, rclass
syntax [anything], [ ///
replace ///
cpivin(string) ///
maindir(string) ///
]

version 14
Expand Down

0 comments on commit b412f49

Please sign in to comment.