library(SmdAid)
stata_pre<<-"out_v1"

```{stata, collectcode=TRUE, echo=FALSE, results="hide"}
global outposix "out_v1" adopath + "D:\Activity\elderman\utils" set linesize 255

```{stata, echo=FALSE, results="hide"}
// 清除報表: 殺掉暫存檔 
local report report
local xfiles : dir `report' files "${outposix}_*.*"

foreach fn of local xfiles {
 erase `report'/`fn'
}

最簡單的範例

```{stata, collectcode=TRUE}

sysuse auto

# 我自己要用的

### regress

```{stata, ,collectcode=TRUE, echo=FALSE, cleanlog=FALSE }
global xalt1 child    
eststo clear
eststo: regress foreign price

報表

``{stata, outposix=linkto("html","## **html外部連結**"),collectcode=TRUE, echo=FALSE, cleanlog=FALSE } genfilename "$outposix",post(.html) pre("report/") autoinc esttab usingr(fn)',starlevels( * 0.10 0.05 * 0.010) r2 pr2 aic replace label mtitle nobaselevel nolines nogaps onecell nonumbers title("104新舊") /// nobaselevel refcat(1.child "子女數(base 0)" /// 2.incom "收入(base 10-)" /// 2.age104 "年齡(base 50-54)" /// 1.educ "教育程度(base 不識字)" /// 1.incom2 "新收入(base 70-)" /// 1.child2 "子女數(base 0)" /// 1.age2 "新年齡(base 50-59)",nolabel)

# 圖
```{stata, outposix=linkto("png","### 圖:直方"), collectcode=TRUE,echo=TRUE,results="hide"}

  graph bar, over(foreign)

  genfilename "$outposix",post(.png) pre("report/") autoinc  
  graph export `r(fn)', as(png) replace 

}

所有程式碼




airbone4/SmdAid documentation built on June 3, 2021, 6:54 a.m.