* Authors: * Program written by Bolin, Song (æ¾æŸæž—) Shenzhen University, China. * Wechat:YJYSY91, 2021-01-02 * Original Data Source: https://data.stats.gov.cn/ * Please do not use this code for commerical purpose capture program drop cngdf program define cngdf version 14.0 syntax [anything] ,YEAR(numlist integer max=1 min=1 ) [CHINA] qui{ if missing("`china'") { *ä¸‹è½½æ•°æ® local URL "https://gitee.com/songbolin/stata/raw/master/8458467434930237.dta" tempfile data cap copy `"`URL'"' "`data'.dta", replace local times = 0 while _rc ~= 0 { local times = `times' + 1 sleep 1000 cap copy `"`URL'"' "`data'.dta", replace if `times' > 10 { disp as error "Internet speeds is too low to get the data" exit 601 } } use "`data'.dta", clear *设置时间区间 local year_small=year[1] local year_big =year[_N] if `year'<`year_small' | `year'>`year_big'{ disp as error `"The year must be between `year_small' and `year_big'"' exit 198 } *计算GDP平凿Œ‡æ•° gen Real_GDP = GDP if year == `year' bysort id :replace Real_GDP= Real_GDP[_n-1]*GDPindex/100 if year!=`year' gen gdp_deflator=GDP/Real_GDP *ç»“æžœåŠ æ ‡ç¾ drop id drop if year<`year' label variable province "çœä»½" label variable year "年份" label variable GDP "å义GDP" label variable Real_GDP "实际GDP" label variable GDPindex "GDP指数" label variable gdp_deflator "以`year'年为基期的GDP平凿Œ‡æ•°" label data "以`year'年为基期的GDP平凿Œ‡æ•°" } else{ *ä¸‹è½½æ•°æ® local URL "https://gitee.com/songbolin/stata/raw/master/8458490029.dta" tempfile data cap copy `"`URL'"' "`data'.dta", replace local times = 0 while _rc ~= 0 { local times = `times' + 1 sleep 1000 cap copy `"`URL'"' "`data'.dta", replace if `times' > 10 { disp as error "Internet speeds is too low to get the data" exit 601 } } *å¯¼å…¥æ•°æ® use "`data'.dta", clear *设置时间区间 local year_small=year[1] local year_big =year[_N] if `year'<`year_small' | `year'>`year_big'{ disp as error `"The year must be between `year_small' and `year_big'"' exit 198 } *计算GDP平凿Œ‡æ•° gen Real_gdp = gdp if year == `year' replace Real_gdp= Real_gdp[_n-1]*gdp_index/100 if year!=`year' gen gdp_deflator=gdp/Real_gdp *ç»“æžœåŠ æ ‡ç¾ drop if year<`year' label variable country "国家" label variable year "年份" label variable gdp "å义GDP" label variable Real_gdp "实际GDP" label variable gdp_index "GDP指数" label variable gdp_deflator "以`year'年为基期的GDP平凿Œ‡æ•°" label data "以`year'年为基期的GDP平凿Œ‡æ•°" } } dis as txt "({stata br:点击打开数æ®})" dis as txt "(åŠ å…¥stata交æµç¾¤å¾®ä¿¡ï¼šsongbl_stata)" end