cchart_7.ado

来自「是一个经济学管理应用软件 很难找的 但是经济学学生又必须用到」· ADO 代码 · 共 32 行

ADO
32 行
字号
*! version 2.1.3  17jun1999
program define cchart_7
	version 6
	syntax varlist(min=2 max=2) [, *] 
	tokenize `varlist'
	local DEFECTS "`1'"
	local UNIT "`2'"
	tempvar CBAR NUNITS
		/*
		   calculate _cbar, the mean number of defects
		*/
	gen long `NUNITS' = sum(`DEFECTS'~=. & `DEFECTS'>=0 & `UNIT'~=.)
	gen float `CBAR' = sum(`DEFECTS')
	local cbar = `CBAR'[_N]/`NUNITS'[_N]
		/*
		   calculate the control limits and draw the c-chart
		*/
	local UCL = `cbar' + 3*sqrt(`cbar')
	local LCL = cond(`cbar'>3*sqrt(`cbar'),`cbar'-3*sqrt(`cbar'),0)
	quietly replace `NUNITS' = sum(`DEFECTS'<`LCL' | `DEFECTS'>`UCL')
	local top "(1 unit is out of control)"
	if `NUNITS'[_N]!=1 {
		local top = `NUNITS'[_N]
		local top = "(`top' units are out of control)"
	}
	#delimit ;
	gr7 `DEFECTS' `UNIT', c(l) s(o) sort `options'
		rlab(`cbar',`UCL',`LCL') yline(`UCL',`LCL')
		t1("`top'") l1("Number of defects") ;
	#delimit cr
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?