Computed theoretical power for N=100 and N=200 scenarios
This commit is contained in:
92
Modules/ado/plus/l/l1way.ado
Normal file
92
Modules/ado/plus/l/l1way.ado
Normal file
@ -0,0 +1,92 @@
|
||||
*! version 1.1.1 STB-35 sg65
|
||||
program define l1way
|
||||
version 4.0
|
||||
local varlist "req ex min(2) max(2)"
|
||||
local if "opt"
|
||||
local in "opt"
|
||||
local weight "aweight"
|
||||
local options "Center(string) Ems"
|
||||
parse "`*'"
|
||||
parse "`varlist'", parse(" ")
|
||||
local weight "[`weight'`exp']"
|
||||
local wt : word 2 of `exp'
|
||||
|
||||
tempvar use
|
||||
quietly {
|
||||
mark `use' `if' `in'
|
||||
markout `use' `varlist' `wt'
|
||||
|
||||
preserve
|
||||
keep if `use'
|
||||
sort `2'
|
||||
if "`wt'" == "" {
|
||||
tempvar Wt
|
||||
gen byte `Wt' = 1
|
||||
local wt "`Wt'"
|
||||
}
|
||||
summ `1' `weight'
|
||||
tempname dft sst msa mse gr
|
||||
scalar S_1 = _result(1)
|
||||
scalar `dft' = _result(1) - 1
|
||||
scalar `sst' = `dft' * _result(4)
|
||||
tempvar tt sw xm
|
||||
gen double `sw' = `wt' in 1 /* sum the weights */
|
||||
replace `sw' = cond(`2' > `2'[_n-1], `wt', `sw'[_n-1] + `wt') in 2/l
|
||||
gen double `xm' = `1' in 1 /* get group means */
|
||||
replace `xm' = cond(`2' > `2'[_n-1], `1', /*
|
||||
*/ `xm'[_n-1] + `wt'*(`1'-`xm'[_n-1])/`sw') in 2/l
|
||||
drop if `2' >= `2'[_n+1] in 1/-2
|
||||
|
||||
summ `xm' [aw=`sw']
|
||||
scalar S_3 = _result(1) - 1
|
||||
scalar `msa' = _result(4) * scalar(S_1) / _result(1)
|
||||
scalar S_2 = scalar(S_3) * `msa'
|
||||
if "`ems'" != "" {
|
||||
replace `sw' = sum(`sw'*`sw')
|
||||
scalar `gr' = (_result(2) - `sw'[_N]/_result(2) )/ scalar(S_3)
|
||||
}
|
||||
else { scalar `gr' = scalar(S_1)/_result(1) }
|
||||
}
|
||||
scalar S_4 = `sst' - scalar(S_2)
|
||||
scalar S_5 = `dft' - scalar(S_3)
|
||||
scalar `mse' = scalar(S_4) / scalar(S_5)
|
||||
scalar S_6 = `msa' / `mse'
|
||||
|
||||
local lab : variable label `1'
|
||||
local lbl /*
|
||||
*/ "One Way Analysis of Variance for `1': `lab'"
|
||||
local indent = int((80-length("`lbl'"))/2)
|
||||
noisily di _n _skip(`indent') in gr "`lbl'"
|
||||
noisily di _n in gr /*
|
||||
*/ _col(5) "Source" _col(25) "SS" /*
|
||||
*/ _col(36) "df" _col(44) "MS" /*
|
||||
*/ _col(58) "F" _col(64) "Prob > F" /*
|
||||
*/ _n _dup(72) "-"
|
||||
noisily di in gr "Between `2'" in yellow /*
|
||||
*/ _col(21) %10.0g scalar(S_2) /*
|
||||
*/ _col(32) %6.0f scalar(S_3) /*
|
||||
*/ _col(41) %10.0g `msa' /*
|
||||
*/ _col(52) %9.2f scalar(S_6) /*
|
||||
*/ _col(66) %6.4f fprob(scalar(S_3), scalar(S_5), scalar(S_6))
|
||||
noisily di in gr "Within `2'" in yellow /*
|
||||
*/ _col(21) %10.0g scalar(S_4) /*
|
||||
*/ _col(32) %6.0f scalar(S_5) /*
|
||||
*/ _col(41) %10.0g `mse' /*
|
||||
*/ _n in gr _dup(72) "-"
|
||||
noisily di in gr "Total" in yellow /*
|
||||
*/ _col(21) %10.0g `sst' /*
|
||||
*/ _col(32) %6.0f `dft' /*
|
||||
*/ _col(41) %10.0g `sst'/`dft'
|
||||
|
||||
scalar `sst' = 1
|
||||
if "`center'" == "mean" { scalar `sst' = scalar(S_5)/(scalar(S_5)-2) }
|
||||
else if "`center'" == "med" {
|
||||
scalar `sst' = invfprob(scalar(S_3), scalar(S_5), 0.5)
|
||||
}
|
||||
scalar `dft' = max(scalar(S_6) - `sst', 0)
|
||||
global S_1 = `dft' / (`dft' + `sst'* `gr')
|
||||
global S_2 = `dft' / (`dft' + `sst')
|
||||
di _new in gr "Intra-`2' r =" in ye %7.4f $S_1 _new in gr /*
|
||||
*/ "Estimated reliability of a `2' mean (n=" in ye %3.2f `gr' in gr /*
|
||||
*/ ") =" in ye %7.4f $S_2
|
||||
end
|
68
Modules/ado/plus/l/l1way.hlp
Normal file
68
Modules/ado/plus/l/l1way.hlp
Normal file
@ -0,0 +1,68 @@
|
||||
.-
|
||||
help for ^iclassr^, ^l1way^
|
||||
.-
|
||||
|
||||
One-way ANOVA, random effects, and intra-class correlation [STB-35 sg65]
|
||||
----------------------------------------------------------
|
||||
|
||||
^iclassr^ response_var group_var [weight] [^if^ exp] [^in^ range]
|
||||
[^, c^enter^(^Fpos^) e^ms ^noi^sily]
|
||||
|
||||
^l1way^ response_var group_var [weight] [^if^ exp] [^in^ range]
|
||||
[^, c^enter^(^Fpos^) e^ms]
|
||||
|
||||
|
||||
^aweight^s are allowed; see help @weights@.
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
^l1way^ and ^iclassr^ estimate one-way analysis of variance (ANOVA) models and use
|
||||
the random effects ANOVA model to estimate the intra-class (within group) cor-
|
||||
relation, and the reliability of group averages from the Spearman-Brown proph-
|
||||
ecy formula.
|
||||
|
||||
^l1way^ and ^iclassr^ are replacements for @loneway@; ^iclassr^ is faster than ^l1way^
|
||||
but limited to fewer than 376 values of group_var. Both are substantially fast-
|
||||
er than ^loneway^, especially ^iclassr^, and both offer more accurate estimation of
|
||||
the intra-class correlation in unbalanced designs or in weighted analyses; see
|
||||
the option ^ems^, below.
|
||||
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
^center^ chooses a reference point in the F distribution to center the observed
|
||||
F statistic in estimating the intra-class correlation. The argument Fpos
|
||||
may be 1 (the default), or "med" or "mean" to choose the median or the mean
|
||||
of the appropriate F distribution. This option has little effect except in
|
||||
small samples.
|
||||
|
||||
^ems^ uses the coefficient of the group variance in the expected value of the be-
|
||||
tween group mean square to scale the estimated intra-class correlation. The
|
||||
default, for compatibility with ^loneway^, is to use the average group size
|
||||
instead. This option is ^very^ strongly recommended unless the design is
|
||||
nearly balanced.
|
||||
|
||||
^noisily^ causes ^iclassr^ to display the ANOVA summary table.
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
. ^iclassr rating stimulus^ (intra-stimulus r, < 376 stimuli, equal n's)
|
||||
. ^l1way rating stimulus^ (intra-stimulus r, ANOVA table, equal n's)
|
||||
|
||||
. ^iclassr trait family, ems^ (intra-family r, < 376 families, unequal n's)
|
||||
. ^l1way trait family, e c(med)^ (intra-family r, unequal n's, center the ob-
|
||||
served F on the median of F)
|
||||
|
||||
|
||||
Also see
|
||||
--------
|
||||
|
||||
STB: sg65 (STB-35)
|
||||
Manual: ^[R] loneway, oneway^
|
||||
On-line: help for @loneway@, @oneway@
|
||||
|
511
Modules/ado/plus/l/labbe.ado
Normal file
511
Modules/ado/plus/l/labbe.ado
Normal file
@ -0,0 +1,511 @@
|
||||
// program runs old graph command in tandem
|
||||
// should be able to use other Stata 10 graph options in `options' once removed
|
||||
// allow labelling of data points? Can extra plots be added?
|
||||
|
||||
*! version 1.22 Sep2003
|
||||
*! version 2.01 Jul2008
|
||||
*Can add lines corresponding to RR, OR and RD measures. Allows the analyst to see the
|
||||
*line fitted to the points (p1,p0)
|
||||
*Also has logit option added
|
||||
|
||||
*2008 update by Ross Harris
|
||||
|
||||
program define labbe
|
||||
version 8
|
||||
syntax varlist(min=4 max=4) [if] [in] /*
|
||||
*/ [, RR(string) RRN(string) RD(string) OR(string) NULL PERCent noWT XLOg YLOg /*
|
||||
*/ SAving(string) YLAbel(string) XLAbel(string) YSCale(string) XSCale(string) LOGIT NOLEGend /*
|
||||
*/ id(varname) CLOCKvar(varname) gap(real 1) textsize(real 1) symbol(string) wgt(varname) * ]
|
||||
|
||||
local lines = 0
|
||||
local cmd_legend = ""
|
||||
|
||||
preserve
|
||||
if "`if'`in'"!="" {
|
||||
qui keep `if' `in'
|
||||
}
|
||||
parse "`varlist'", parse(" ")
|
||||
tempvar r1 r2 N /* id yrange xrange hsqrwt */
|
||||
if ~( `1'>=0 & `2'>=0 & `3'>=0 & `4'>=0 ) {
|
||||
di in re "Negative cell counts encountered"
|
||||
exit 198
|
||||
}
|
||||
qui gen `r1'=`1'/(`1'+`2')
|
||||
qui gen `r2'=`3'/(`3'+`4')
|
||||
cap assert ((`r1'>=0 & `r1'<=1) | `r1'==.) & ((`r2'>=0 & `r2'<=1 ) | `r2'==. )
|
||||
if _rc!=0 {
|
||||
di in re "Data incorrectly specified"
|
||||
exit 198
|
||||
}
|
||||
qui gen `N' =`1'+`2'+`3'+`4'
|
||||
if "`wt'"=="" {
|
||||
if "`wgt'" != ""{
|
||||
local weight "[weight=`wgt']"
|
||||
}
|
||||
else{
|
||||
local weight "[weight=`N']"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*display logit scale if needed
|
||||
if "`logit'"!="" {
|
||||
cap {
|
||||
assert (`r1'>0) & (`r2'>0)
|
||||
assert (`r1'<1) & (`r2'<1)
|
||||
}
|
||||
if _rc!=0 {
|
||||
di in re "Non-finite values encountered"
|
||||
exit
|
||||
}
|
||||
qui replace `r1'=log(`r1'/(1-`r1'))
|
||||
qui replace `r2'=log(`r2'/(1-`r2'))
|
||||
local subtitl ", logit scale"
|
||||
}
|
||||
|
||||
label var `r1' "Event rate group 1`subtitl'"
|
||||
label var `r2' "Event rate group 2`subtitl'"
|
||||
if strpos("`options'","xtitle(") == 0 & strpos("`options'","ytitle(") == 0{
|
||||
local ytitle "Event rate group 1`subtitl'"
|
||||
local xtitle "Event rate group 2`subtitl'"
|
||||
}
|
||||
|
||||
if "`percent'"!="" {
|
||||
if "`logit'"!="" {
|
||||
di in re "percent option not valid with logit"
|
||||
exit
|
||||
}
|
||||
qui replace `r1'=100*`r1'
|
||||
qui replace `r2'=100*`r2'
|
||||
local scale=100
|
||||
}
|
||||
else {
|
||||
local scale=1
|
||||
}
|
||||
|
||||
if ("`xlog'`ylog'"!="") {
|
||||
if ("`logit'"!="") {
|
||||
di in re "Cannot use logit and xlog or ylog"
|
||||
exit
|
||||
}
|
||||
if "`rr'`or'`rd'`rrn'"!="" {
|
||||
di in re "Cannot use rr(), or(), rd() or rrn() with xlog or ylog"
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
if "`xlabel'`ylabel'`yscale'`xscale'"=="" {
|
||||
local zero=0
|
||||
if "`percent'"!="" {
|
||||
if "`xlog'`ylog'"!="" {
|
||||
local zero=1
|
||||
}
|
||||
local ylabel "ylabel(`zero',25,50,75,100)"
|
||||
local xlabel "xlabel(`zero',25,50,75,100)"
|
||||
}
|
||||
if "`percent'"=="" & "`logit'"=="" {
|
||||
if "`xlog'`ylog'"!="" {
|
||||
local zero=0.01
|
||||
}
|
||||
local ylabel "ylabel(`zero',0.25,0.5,0.75,1)"
|
||||
local xlabel "xlabel(`zero',0.25,0.5,0.75,1)"
|
||||
}
|
||||
if "`percent'"=="" & "`logit'"!="" {
|
||||
*make own labels if on logit scale
|
||||
qui sum `r1'
|
||||
local r1min=r(min)
|
||||
local r1max=r(max)
|
||||
qui sum `r2'
|
||||
local r2min=r(min)
|
||||
local r2max=r(max)
|
||||
local lo=min(`r1min',`r2min')
|
||||
local hi=max(`r1max',`r2max')
|
||||
local ylabel "ylabel(`lo',`hi')"
|
||||
local xlabel "xlabel(`lo',`hi')"
|
||||
}
|
||||
}
|
||||
else {
|
||||
if "`ylabel'"!="" {
|
||||
local ylabel "ylabel(`ylabel')"
|
||||
}
|
||||
if "`xlabel'"!="" {
|
||||
local xlabel "xlabel(`xlabel')"
|
||||
}
|
||||
if "`yscale'"!="" {
|
||||
local yscale "yscale(range(`yscale'))"
|
||||
}
|
||||
if "`xscale'"!="" {
|
||||
local xscale "xscale(range(`xscale'))"
|
||||
}
|
||||
}
|
||||
|
||||
if "`saving'"!="" {
|
||||
local saving "saving(`saving')"
|
||||
}
|
||||
*graph `r1' `r2' `weight' , `options' `xlog' `ylog' `xlabel' `ylabel' `xscale' `yscale'
|
||||
*gph open, `saving'
|
||||
*graph
|
||||
local ay=r(ay)
|
||||
local by=r(by)
|
||||
local ax=r(ax)
|
||||
local bx=r(bx)
|
||||
local ymax=r(ymax)
|
||||
local ymin=r(ymin)
|
||||
local xmax=r(xmax)
|
||||
local xmin=r(xmin)
|
||||
local Grmax=min(`ymax', `xmax')
|
||||
local Grmin=max(`ymin', `xmin')
|
||||
|
||||
local xvals = subinstr("`xlabel'","xlabel(","",.)
|
||||
local yvals = subinstr("`ylabel'","ylabel(","",.)
|
||||
local xvals = subinstr("`xvals'",")","",.)
|
||||
local yvals = subinstr("`yvals'",")","",.)
|
||||
local xvals2 = subinstr("`xscale'","xscale(range(","",.)
|
||||
local yvals2 = subinstr("`yscale'","yscale(range(","",.)
|
||||
local xvals2 = subinstr("`xvals2'","))","",.)
|
||||
local yvals2 = subinstr("`yvals2'","))","",.)
|
||||
|
||||
// need to find graph widths etc. manually
|
||||
qui summ `r1'
|
||||
local ymin = r(min)
|
||||
local ymax = r(max)
|
||||
if "`yvals'" != ""{
|
||||
local ymin = min(`ymin',`yvals')
|
||||
local ymax = max(`ymax',`yvals')
|
||||
}
|
||||
if "`yvals2'" != ""{
|
||||
local ymin = min(`ymin',`yvals2')
|
||||
local ymax = max(`ymax',`yvals2')
|
||||
}
|
||||
qui summ `r2'
|
||||
local xmin = r(min)
|
||||
local xmax = r(max)
|
||||
if "`xvals'" != ""{
|
||||
local xmin = min(`xmin',`xvals')
|
||||
local xmax = max(`xmax',`xvals')
|
||||
}
|
||||
if "`xvals2'" != ""{
|
||||
local xmin = min(`xmin',`xvals2')
|
||||
local xmax = max(`xmax',`xvals2')
|
||||
}
|
||||
local aspect = (`ymax'-`ymin')/(`xmax'-`xmin')
|
||||
|
||||
*trap errors :RR, OR,RRN need to be positive; RD in range -1 to 1
|
||||
local flag= 0
|
||||
|
||||
*gph font 300 200
|
||||
if "`xlog'"!="" {
|
||||
local xlog "log"
|
||||
}
|
||||
if "`ylog'"!="" {
|
||||
local ylog "log"
|
||||
}
|
||||
|
||||
if "`null'"!="" {
|
||||
*Draw null line
|
||||
if `ymin' < `xmin'{
|
||||
local Axco0 = `xmin'
|
||||
local Ayco0 = `xmin'
|
||||
}
|
||||
else{
|
||||
local Axco0 = `ymin'
|
||||
local Ayco0 = `ymin'
|
||||
}
|
||||
if `ymax' > `xmax'{
|
||||
local Axco1 = `xmax'
|
||||
local Ayco1 = `xmax'
|
||||
}
|
||||
else{
|
||||
local Axco1 = `ymax'
|
||||
local Ayco1 = `ymax'
|
||||
}
|
||||
local cmd_null = "(scatteri `Ayco0' `Axco0' `Ayco1' `Axco1', recast(line) lpattern(dash) lcolor(gs6))"
|
||||
local lines = `lines'+1
|
||||
local q = char(34)
|
||||
local cmd_legend = "`cmd_legend' `lines' "+ `"`q'"' + "Null" + `"`q'"'
|
||||
|
||||
}
|
||||
|
||||
if "`or'"!="" & "`logit'"=="" {
|
||||
*gph pen 5
|
||||
parse "`or'", parse(",")
|
||||
while "`1'"!="" {
|
||||
local or_gph=`1'
|
||||
if (`or_gph'<=0 ) {
|
||||
local flag=10
|
||||
}
|
||||
else {
|
||||
if `ymin' > `scale'*(`or_gph'*`xmin'/(`scale'*1-`xmin'+(`or_gph'*`xmin'))) {
|
||||
local yco0=`ymin'
|
||||
local xco0=`ymin'/(`scale'*`or_gph'+`ymin'-`ymin'*`or_gph')
|
||||
}
|
||||
else {
|
||||
local yco0=`scale'*`or_gph'*`xmin'/(`scale'*1-`xmin'+(`or_gph'*`xmin'))
|
||||
local xco0=`xmin'
|
||||
}
|
||||
local Ayco0=`ay'*`yco0' + `by'
|
||||
local Axco0=`ax'*`xco0' + `bx'
|
||||
if `xmax' < (`scale'*`ymax'/(`scale'*`or_gph'+`ymax'-(`or_gph'*`ymax'))) {
|
||||
local cgermax = `xmax'
|
||||
}
|
||||
else {
|
||||
local cgermax = (`scale'*`ymax'/(`scale'*`or_gph'+`ymax'-(`or_gph'*`ymax')))
|
||||
}
|
||||
local cger=`xco0'
|
||||
while `cger'<=`cgermax' {
|
||||
local cger = `cger'+`scale'*0.005
|
||||
local tger = `scale'*`or_gph'*`cger'/(`scale'*1-`cger'+(`or_gph'*`cger'))
|
||||
local Ayco1= `ay'*`tger'+`by'
|
||||
local Axco1= `ax'*`cger'+`bx'
|
||||
local sub_cmds "`sub_cmds' `tger' `cger'"
|
||||
local Ayco0=`Ayco1'
|
||||
local Axco0=`Axco1'
|
||||
}
|
||||
local cmd_or "(scatteri `sub_cmds', recast(line) lcolor(maroon))"
|
||||
local lines = `lines'+1
|
||||
local q = char(34)
|
||||
local cmd_legend = `"`cmd_legend'"' + " `lines' " + `"`q'"' + "Odds ratio" + `"`q'"'
|
||||
}
|
||||
mac shift 2
|
||||
}
|
||||
}
|
||||
|
||||
if "`or'"!="" & "`logit'"!="" {
|
||||
*gph pen 9
|
||||
parse "`or'", parse(",")
|
||||
while "`1'"!="" {
|
||||
if (`1'<=0 ) {
|
||||
local flag=10
|
||||
}
|
||||
else {
|
||||
local or_lgph=log(`1')
|
||||
if `ymin' > `xmin'+`or_lgph' {
|
||||
local yco0=`ymin'
|
||||
local xco0=`ymin'-`or_lgph'
|
||||
}
|
||||
else {
|
||||
local yco0=`xmin'+`or_lgph'
|
||||
local xco0=`xmin'
|
||||
}
|
||||
if `ymax' >`xmax'+`or_lgph' {
|
||||
local yco1=`xmax'+`or_lgph'
|
||||
local xco1=`xmax'
|
||||
}
|
||||
else {
|
||||
local yco1=`ymax'
|
||||
local xco1=`ymax'-`or_lgph'
|
||||
}
|
||||
local Ayco0=`ay'*`yco0' + `by'
|
||||
local Axco0=`ax'*`xco0' + `bx'
|
||||
local Ayco1=`ay'*`yco1' + `by'
|
||||
local Axco1=`ax'*`xco1' + `bx'
|
||||
if ( (`ymax'>`yco0') & (`xmax'>`xco0') & (`ymin'<`yco1') & (`xmin'<`xco1') ) {
|
||||
*gph line `Ayco0' `Axco0' `Ayco1' `Axco1'
|
||||
local cmd_or2 = "(scatteri `yco0' `xco0' `yco1' `xco1', recast(line) lcolor(maroon))"
|
||||
local lines = `lines'+1
|
||||
local q = char(34)
|
||||
local cmd_legend = `"`cmd_legend'"' + " `lines' " + `"`q'"' + "Odds ratio" + `"`q'"'
|
||||
}
|
||||
}
|
||||
mac shift 2
|
||||
}
|
||||
}
|
||||
|
||||
if "`rr'"!="" {
|
||||
if "`logit'"!="" {
|
||||
di in re "rr option not valid with logit"
|
||||
exit
|
||||
}
|
||||
*gph pen 6
|
||||
parse "`rr'", parse(",")
|
||||
while "`1'"!="" {
|
||||
local rr_gph=`1'
|
||||
if (`rr_gph'<=0 ) {
|
||||
local flag=10
|
||||
}
|
||||
else {
|
||||
if `ymin' > `rr_gph'*`xmin' {
|
||||
local yco0=`ymin'
|
||||
local xco0=`ymin'/`rr_gph'
|
||||
}
|
||||
else {
|
||||
local yco0=`rr_gph'*`xmin'
|
||||
local xco0=`xmin'
|
||||
}
|
||||
if `ymax' > `rr_gph'*`xmax' {
|
||||
local yco1=`rr_gph'*`xmax'
|
||||
local xco1=`xmax'
|
||||
}
|
||||
else {
|
||||
local yco1=`ymax'
|
||||
local xco1=`ymax'/`rr_gph'
|
||||
}
|
||||
local Ayco0=`ay'*`yco0' + `by'
|
||||
local Axco0=`ax'*`xco0' + `bx'
|
||||
local Ayco1=`ay'*`yco1' + `by'
|
||||
local Axco1=`ax'*`xco1' + `bx'
|
||||
if ( (`ymax'>`yco0') & (`xmax'>`xco0') & (`ymin'<`yco1') & (`xmin'<`xco1') ) {
|
||||
*gph line `Ayco0' `Axco0' `Ayco1' `Axco1'
|
||||
local cmd_rr = "(scatteri `yco0' `xco0' `yco1' `xco1', recast(line) lcolor(dkgreen))"
|
||||
local lines = `lines'+1
|
||||
local q = char(34)
|
||||
local cmd_legend = `"`cmd_legend'"' + " `lines' " + `"`q'"' + "Risk ratio" + `"`q'"'
|
||||
}
|
||||
}
|
||||
mac shift 2
|
||||
}
|
||||
}
|
||||
|
||||
if "`rrn'"!="" {
|
||||
if "`logit'"!="" {
|
||||
di in re "rrn option not valid with logit"
|
||||
exit
|
||||
}
|
||||
*gph pen 7
|
||||
parse "`rrn'", parse(",")
|
||||
while "`1'"!="" {
|
||||
local rrn_gph=`1'
|
||||
if (`rrn_gph'<=0 ) {
|
||||
local flag=10
|
||||
}
|
||||
else {
|
||||
if `ymin' > (`scale'*(1 -`rrn_gph') + `rrn_gph'*`xmin') {
|
||||
local yco0=`ymin'
|
||||
local xco0=(`ymin'+`scale'*(`rrn_gph'-1))/`rrn_gph'
|
||||
}
|
||||
else {
|
||||
local yco0=`scale'*(1-`rrn_gph') + `rrn_gph'*`xmin'
|
||||
local xco0=`xmin'
|
||||
}
|
||||
if `ymax' >(`scale'*(1-`rrn_gph') + `rrn_gph'*`xmax' ) {
|
||||
local yco1=`scale'*(1-`rrn_gph') + `rrn_gph'*`xmax'
|
||||
local xco1=`xmax'
|
||||
}
|
||||
else {
|
||||
local yco1=`ymax'
|
||||
local xco1=(`ymax'+`scale'*(`rrn_gph'-1))/`rrn_gph'
|
||||
}
|
||||
local Ayco0=`ay'*`yco0' + `by'
|
||||
local Axco0=`ax'*`xco0' + `bx'
|
||||
local Ayco1=`ay'*`yco1' + `by'
|
||||
local Axco1=`ax'*`xco1' + `bx'
|
||||
if ( (`ymax'>`yco0') & (`xmax'>`xco0') & (`ymin'<`yco1') & (`xmin'<`xco1') ) {
|
||||
*gph line `Ayco0' `Axco0' `Ayco1' `Axco1'
|
||||
local cmd_rrn = "(scatteri `yco0' `xco0' `yco1' `xco1', recast(line) lcolor(ltgreen))"
|
||||
local lines = `lines'+1
|
||||
local q = char(34)
|
||||
local cmd_legend = `"`cmd_legend'"' + " `lines' " + `"`q'"' + "Risk ratio (non-event)" + `"`q'"'
|
||||
}
|
||||
}
|
||||
mac shift 2
|
||||
}
|
||||
}
|
||||
|
||||
if "`rd'"!="" {
|
||||
if "`logit'"!="" {
|
||||
di in re "rd option not valid with logit"
|
||||
exit
|
||||
}
|
||||
*gph pen 8
|
||||
parse "`rd'", parse(",")
|
||||
while "`1'"!="" {
|
||||
local rd_gph=`1'
|
||||
if (`rd_gph'<=-1 | `rd_gph'>=1 ) {
|
||||
local flag=10
|
||||
}
|
||||
else {
|
||||
if `ymin' > `xmin'+`scale'*`rd_gph' {
|
||||
local yco0=`ymin'
|
||||
local xco0=`ymin'-`scale'*`rd_gph'
|
||||
}
|
||||
else {
|
||||
local yco0=`xmin'+`scale'*`rd_gph'
|
||||
local xco0=`xmin'
|
||||
}
|
||||
if `ymax' >`xmax'+`rd_gph' {
|
||||
local yco1=`xmax'+`scale'*`rd_gph'
|
||||
local xco1=`xmax'
|
||||
}
|
||||
else {
|
||||
local yco1=`ymax'
|
||||
local xco1=`ymax'-`scale'*`rd_gph'
|
||||
}
|
||||
local Ayco0=`ay'*`yco0' + `by'
|
||||
local Axco0=`ax'*`xco0' + `bx'
|
||||
local Ayco1=`ay'*`yco1' + `by'
|
||||
local Axco1=`ax'*`xco1' + `bx'
|
||||
if ( (`ymax'>`yco0') & (`xmax'>`xco0') & (`ymin'<`yco1') & (`xmin'<`xco1') ) {
|
||||
*gph line `Ayco0' `Axco0' `Ayco1' `Axco1'
|
||||
local cmd_rd = "(scatteri `yco0' `xco0' `yco1' `xco1', recast(line) lcolor(olive))"
|
||||
local lines = `lines'+1
|
||||
local q = char(34)
|
||||
local cmd_legend = `"`cmd_legend'"' + " `lines' " + `"`q'"' + "Risk difference" + `"`q'"'
|
||||
}
|
||||
}
|
||||
mac shift 2
|
||||
}
|
||||
}
|
||||
|
||||
*gph close
|
||||
if `flag'>1 {
|
||||
display _n "Note: some effect sizes are outside valid ranges"
|
||||
}
|
||||
|
||||
// RJH EDIT
|
||||
// sort out xlabel etc. later
|
||||
|
||||
local xlabel = subinstr("`xlabel'", "," ," " ,.)
|
||||
local ylabel = subinstr("`ylabel'", "," ," " ,.)
|
||||
local q = char(34)
|
||||
local l2 = `lines'+1
|
||||
local cmd_legend = `"`cmd_legend'"' + " `l2' " + `"`q'"' + "Studies" + `"`q'"'
|
||||
if `"`cmd_legend'"' != ""{
|
||||
local cmd_legend = "legend(order(" + `"`cmd_legend'"' + ") span)"
|
||||
}
|
||||
if "`nolegend'" != "" | (`lines' == 2 & "`null'" != "") | (`lines'<=1){
|
||||
local cmd_legend = "legend(off)"
|
||||
}
|
||||
|
||||
if "`id'" != ""{
|
||||
tempvar clockVar
|
||||
local lsize = min(`textsize'*30/_N,2)
|
||||
qui gen `clockVar' = `r2'<`r1'
|
||||
qui replace `clockVar' = 3+`clockVar'*6
|
||||
if "`clockvar'" != ""{
|
||||
qui replace `clockVar' = `clockvar' if `clockvar' < . // user defined
|
||||
}
|
||||
tempvar r11 r22 radians
|
||||
qui summ `N'
|
||||
qui gen `radians' = (`clockVar'/12)*2*_pi
|
||||
if `gap' == 0{
|
||||
local gap = 0.0001
|
||||
}
|
||||
local invgap = 17/`gap' // smaller means more gap
|
||||
qui gen `r11' = `r1' + `N'/r(max)*((`ymax'-`ymin')/`invgap')*cos(`radians')
|
||||
qui gen `r22' = `r2' + `N'/r(max)*((`xmax'-`xmin')/`invgap')*sin(`radians')
|
||||
|
||||
local cmd_lab "(scatter `r11' `r22', msymbol(none) mlabel(`id') mlabvposition(`clockVar') mlabcolor(black) mlabsize(`lsize'))"
|
||||
}
|
||||
|
||||
if "`symbol'" == ""{
|
||||
local s2 = "circle_hollow"
|
||||
}
|
||||
else{
|
||||
local s2 = "`symbol'"
|
||||
}
|
||||
if "`weight'" == ""{
|
||||
qui replace `r22' = `r2'
|
||||
qui replace `r11' = `r1'
|
||||
if "`symbol'" == ""{
|
||||
local s2 = "default"
|
||||
}
|
||||
}
|
||||
|
||||
qui twoway `cmd_null' `cmd_or' `cmd_or2' `cmd_rr' `cmd_rrn' `cmd_rd' ///
|
||||
(scatter `r1' `r2' `weight', msymbol(`s2') mcolor(navy)) `cmd_lab' ///
|
||||
, `options' `xlog' `ylog' `xlabel' `ylabel' `xscale' `yscale' ///
|
||||
`cmd_legend' xtitle("`xtitle'") ytitle("`ytitle'") aspect(`aspect')
|
||||
|
||||
restore
|
||||
end
|
||||
|
180
Modules/ado/plus/l/labbe.dlg
Normal file
180
Modules/ado/plus/l/labbe.dlg
Normal file
@ -0,0 +1,180 @@
|
||||
/*
|
||||
|
||||
*! laabe dialog version 1.0.2, 3 Jun 2003, T. J. Steichen, steichen@triad.rr.com
|
||||
*! for laabe version 1.21 24 Mar 2003 M. J. Bradburn, mike.bradburn@cancer.org.uk
|
||||
|
||||
L'abbe Graph
|
||||
------------
|
||||
|
||||
Syntax: labbe varlist [if exp] [in range] [weight] , [ nowt percent
|
||||
or(#,...,#) rr(#,...,#) rd(#,...,#) rrn(#,...,#) null logit graph options ]
|
||||
|
||||
To install in User Statistics menu via Stata commands:
|
||||
. window menu append item "stUserStatistics" "Metan-based L'abbe Graph (&labbe)" "db labbe"
|
||||
. window menu refresh
|
||||
To permanently install, place the commands in your -profile.do- file.
|
||||
|
||||
*/
|
||||
|
||||
VERSION 8.0
|
||||
|
||||
INCLUDE _std_small
|
||||
INCLUDE header
|
||||
|
||||
HELP hlp1, view("help metan")
|
||||
RESET res1, label("Reset")
|
||||
|
||||
DIALOG main, label("labbe 1.21 - Metan-based L'abbe Graph") tabtitle("Main")
|
||||
BEGIN
|
||||
TEXT tx_binary 10 5 330 ., ///
|
||||
label("Vars for Counts a, b, c, d, in that order")
|
||||
VARLIST vl_binary @ _ss @ ., ///
|
||||
label("Vars for a, b, c, d")
|
||||
|
||||
/* end vars */
|
||||
|
||||
CHECKBOX cb_nowt 10 50 130 ., ///
|
||||
label("Symbols not sized") ///
|
||||
option("nowt")
|
||||
|
||||
CHECKBOX cb_percent 10 70 130 ., ///
|
||||
label("Event Rates in %") ///
|
||||
option("percent")
|
||||
|
||||
CHECKBOX cb_null 10 100 130 ., ///
|
||||
label("Draw p1=p2 line") ///
|
||||
option("null")
|
||||
|
||||
CHECKBOX cb_logit 10 130 130 ., ///
|
||||
label("Use logit scale") ///
|
||||
option("logit")
|
||||
|
||||
/* end switches */
|
||||
|
||||
GROUPBOX gb_lines 170 48 175 108, ///
|
||||
label("Draw Lines at:")
|
||||
|
||||
CHECKBOX cb_or 180 +20 80 ., ///
|
||||
label("OR: (>0)") ///
|
||||
onclickon(program or_on) ///
|
||||
onclickoff(script or_off)
|
||||
EDIT ed_or 265 @ 70 ., ///
|
||||
label("or") ///
|
||||
option("or")
|
||||
|
||||
CHECKBOX cb_rd 180 +20 80 ., ///
|
||||
label("RD: (-1,1)") ///
|
||||
onclickon(script rd_on) ///
|
||||
onclickoff(program rd_off)
|
||||
EDIT ed_rd 265 @ 70 ., ///
|
||||
label("rd") ///
|
||||
option("rd")
|
||||
|
||||
CHECKBOX cb_rr 180 +20 80 ., ///
|
||||
label("RR: (>0)") ///
|
||||
onclickon(script rr_on) ///
|
||||
onclickoff(program rr_off)
|
||||
EDIT ed_rr 265 @ 70 ., ///
|
||||
label("rr") ///
|
||||
option("rr")
|
||||
|
||||
CHECKBOX cb_rrn 180 +20 80 ., ///
|
||||
label("RRN: (>0)") ///
|
||||
onclickon(script rrn_on) ///
|
||||
onclickoff(program rrn_off)
|
||||
EDIT ed_rrn 265 @ 70 ., ///
|
||||
label("rrn") ///
|
||||
option("rrn")
|
||||
|
||||
/* end sets */
|
||||
|
||||
GROUPBOX gb_gopts7 10 155 330 _ht1h, ///
|
||||
label("Allowed Graph7 Options:")
|
||||
EDIT ed_gopts7 15 175 320 ., ///
|
||||
label("Graph7 Options")
|
||||
|
||||
/* end Graph7 opts */
|
||||
|
||||
END
|
||||
|
||||
INCLUDE ifin
|
||||
INCLUDE weights_a
|
||||
|
||||
PROGRAM or_on
|
||||
BEGIN
|
||||
call main.ed_or.enable
|
||||
if !(main.cb_rd | main.cb_rr | main.cb_rrn) {
|
||||
call main.cb_logit.enable
|
||||
}
|
||||
END
|
||||
|
||||
SCRIPT or_off
|
||||
BEGIN
|
||||
main.ed_or.disable
|
||||
main.cb_logit.setoff
|
||||
main.cb_logit.disable
|
||||
END
|
||||
|
||||
SCRIPT rd_on
|
||||
BEGIN
|
||||
main.ed_rd.enable
|
||||
main.cb_logit.setoff
|
||||
main.cb_logit.disable
|
||||
END
|
||||
|
||||
PROGRAM rd_off
|
||||
BEGIN
|
||||
call main.ed_rd.disable
|
||||
if main.cb_or & !(main.cb_rr | main.cb_rrn) {
|
||||
call main.cb_logit.enable
|
||||
}
|
||||
END
|
||||
|
||||
SCRIPT rr_on
|
||||
BEGIN
|
||||
main.ed_rr.enable
|
||||
main.cb_logit.setoff
|
||||
main.cb_logit.disable
|
||||
END
|
||||
|
||||
PROGRAM rr_off
|
||||
BEGIN
|
||||
call main.ed_rr.disable
|
||||
if main.cb_or & !(main.cb_rd | main.cb_rrn) {
|
||||
call main.cb_logit.enable
|
||||
}
|
||||
END
|
||||
|
||||
SCRIPT rrn_on
|
||||
BEGIN
|
||||
main.ed_rrn.enable
|
||||
main.cb_logit.setoff
|
||||
main.cb_logit.disable
|
||||
END
|
||||
|
||||
PROGRAM rrn_off
|
||||
BEGIN
|
||||
call main.ed_rrn.disable
|
||||
if main.cb_or & !(main.cb_rd | main.cb_rr) {
|
||||
call main.cb_logit.enable
|
||||
}
|
||||
END
|
||||
|
||||
PROGRAM command
|
||||
BEGIN
|
||||
put "labbe "
|
||||
varlist main.vl_binary
|
||||
INCLUDE _weights_pr
|
||||
INCLUDE _ifin_pr
|
||||
beginoptions
|
||||
option main.cb_nowt
|
||||
option main.cb_percent
|
||||
option main.cb_null
|
||||
option main.cb_logit
|
||||
optionarg main.ed_or
|
||||
optionarg main.ed_rd
|
||||
optionarg main.ed_rr
|
||||
optionarg main.ed_rrn
|
||||
put main.ed_gopts7
|
||||
endoptions
|
||||
END
|
2
Modules/ado/plus/l/labbe.hlp
Normal file
2
Modules/ado/plus/l/labbe.hlp
Normal file
@ -0,0 +1,2 @@
|
||||
.h metan
|
||||
|
32
Modules/ado/plus/l/lclist.ado
Normal file
32
Modules/ado/plus/l/lclist.ado
Normal file
@ -0,0 +1,32 @@
|
||||
program def lclist, rclass
|
||||
*! NJC 1.0.0 29 June 2000
|
||||
version 6.0
|
||||
gettoken list 0 : 0, parse(",")
|
||||
if "`list'" == "" | "`list'" == "," {
|
||||
di in r "nothing in list"
|
||||
exit 198
|
||||
}
|
||||
syntax , [ Global(str) Noisily ]
|
||||
|
||||
if length("`global'") > 8 {
|
||||
di in r "global name must be <=8 characters"
|
||||
exit 198
|
||||
}
|
||||
|
||||
tokenize `list'
|
||||
|
||||
while "`1'" != "" {
|
||||
if length("`1'") > 80 {
|
||||
di in r "cannot handle word length > 80"
|
||||
exit 498
|
||||
}
|
||||
local 1 = lower("`1'")
|
||||
local newlist "`newlist'`1' "
|
||||
mac shift
|
||||
}
|
||||
|
||||
if "`noisily'" != "" { di "`newlist'" }
|
||||
if "`global'" != "" { global `global' "`newlist'" }
|
||||
return local list `newlist'
|
||||
end
|
||||
|
2
Modules/ado/plus/l/lclist.hlp
Normal file
2
Modules/ado/plus/l/lclist.hlp
Normal file
@ -0,0 +1,2 @@
|
||||
.h listutil
|
||||
|
BIN
Modules/ado/plus/l/lconfa.mlib
Normal file
BIN
Modules/ado/plus/l/lconfa.mlib
Normal file
Binary file not shown.
66
Modules/ado/plus/l/leastlikely.ado
Normal file
66
Modules/ado/plus/l/leastlikely.ado
Normal file
@ -0,0 +1,66 @@
|
||||
*! 1.0.2 - 9/28/02 - Jeremy Freese
|
||||
capture program drop leastlikely
|
||||
program define leastlikely
|
||||
version 7.0
|
||||
|
||||
syntax [varlist(default=none)] [if] [in] [, n(integer 5) Generate(string) *]
|
||||
|
||||
if "`e(cmd)'"=="clogit" | "`e(cmd)'"=="nlogit" | "`e(cmd)'"=="xtlogit" | /*
|
||||
*/ "`e(cmd)'"=="blogit" | "`e(cmd)'"=="bprobit" | "`e(cmd)'"=="glogit" | /*
|
||||
*/ "`e(cmd)'"=="gprobit" {
|
||||
di _n as err "leastlikely not intended for use after `e(cmd)'"
|
||||
exit 198
|
||||
}
|
||||
|
||||
local erase "no"
|
||||
tempname values prob touse
|
||||
local depvar = "`e(depvar)'"
|
||||
local depvarlabel : value label `depvar'
|
||||
if "`generate'"=="" {
|
||||
local generate "Prob"
|
||||
local erase "yes"
|
||||
}
|
||||
quietly {
|
||||
gen `touse' = e(sample) `if' `in'
|
||||
gen `prob' = .
|
||||
tabulate `depvar' if e(sample)==1, matrow(`values')
|
||||
local temp : rownames `values'
|
||||
local numcats : word count `temp'
|
||||
forvalues i = 1(1)`numcats' {
|
||||
local value`i' = `values'[`i', 1]
|
||||
}
|
||||
local isbin "no"
|
||||
if `numcats'==2 & `value1'==0 & `value2'==1 { local isbin "yes" }
|
||||
if "`isbin'" == "yes" {
|
||||
tempname temp
|
||||
predict `temp', p
|
||||
replace `prob' = `temp' if `depvar'==1 & `touse'==1
|
||||
replace `prob' = (1-`temp') if `depvar'==0 & `touse'==1
|
||||
}
|
||||
if "`isbin'" == "no" {
|
||||
forvalues i = 1(1)`numcats' {
|
||||
tempname temp
|
||||
predict `temp', outcome(`value`i'')
|
||||
replace `prob' = `temp' if `depvar'==`value`i'' & `touse'==1
|
||||
}
|
||||
}
|
||||
gen `generate' = `prob'
|
||||
}
|
||||
|
||||
forvalues i = 1(1)`numcats' {
|
||||
local vallabel ""
|
||||
if "`depvarlabel'"!="" {
|
||||
local vallabel : label `depvarlabel' `value`i''
|
||||
if "`vallabel'"!="" { local vallabel = "(`vallabel')" }
|
||||
}
|
||||
di _n as txt "Outcome: " as res `value`i'' " `vallabel'"
|
||||
|
||||
tempname temp
|
||||
quietly egen `temp' = rank(`generate') if `depvar'==`value`i'' & `touse'==1, track
|
||||
list `generate' `varlist' if `temp'<=`n' , `options'
|
||||
}
|
||||
|
||||
if "`erase'"=="yes" { drop `generate' }
|
||||
|
||||
end
|
||||
|
85
Modules/ado/plus/l/leastlikely.hlp
Normal file
85
Modules/ado/plus/l/leastlikely.hlp
Normal file
@ -0,0 +1,85 @@
|
||||
{smcl}
|
||||
{* 19nov2002}{...}
|
||||
{hline}
|
||||
help for {hi:leastlikely}{right:(SJ2-4: st0022_1)}
|
||||
{hline}
|
||||
|
||||
{title:List least likely observations}
|
||||
|
||||
{p 8 13}{cmd:leastlikely} [{it:varlist}] [{cmd:if} {it:exp}]
|
||||
[{cmd:in} {it:range}]
|
||||
[{cmd:,} {cmd:n(}{it:#}{cmd:)} {cmdab:g:enerate(}{it:varname}{cmd:)}
|
||||
[{cmdab:no:}]{cmdab:d:isplay} {cmdab:nol:abel} {cmdab:noo:bs}
|
||||
{cmdab:do:ublespace}]
|
||||
|
||||
|
||||
{title:Description}
|
||||
|
||||
{p 4 4 2}For regression models for categorical dependent variables,
|
||||
{cmd:leastlikely} lists the in-sample observations with the lowest
|
||||
predicted probabilities of observing the outcome value that was
|
||||
actually observed. For example, in a model with a binary dependent
|
||||
variable, {cmd:leastlikely} lists the observations that have the lowest
|
||||
predicted probability of {it:depvar=0} among those cases for which
|
||||
{it:depvar=0}, and it lists the observations that have the lowest predicted
|
||||
probability of {it: depvar=1} among those cases for which {it:depvar=1}. The
|
||||
least likely values represent relatively deviant cases that may warrant
|
||||
closer inspection.
|
||||
|
||||
{p 4 4 2}{cmd:leastlikely} works with estimation commands for models of binary
|
||||
outcomes in which option {cmd:p} after {cmd:predict} provides the predicted
|
||||
probability of a positive outcome (e.g., {cmd:logit}, {cmd:probit}), but the
|
||||
dependent variable must be coded as 0 and 1. Likewise, {cmd:leastlikely}
|
||||
works with estimation commands for models of ordinal or nominal outcomes
|
||||
in which option {cmd:outcome(}{it:#}{cmd:)} after {cmd: predict} provides the
|
||||
predicted probability of outcome {it:#}. Exceptions are commands in which the
|
||||
predicted probabilities are probabilities within groups or panels or for
|
||||
"blocked" data; {cmd:leastlikely} will produce an error message if executed
|
||||
after {cmd:blogit}, {cmd:bprobit}, {cmd:clogit}, {cmd:glogit},
|
||||
{cmd:gprobit}, {cmd:nlogit}, or {cmd:xtlogit}.
|
||||
|
||||
{p 4 4 2}{cmd:leastlikely} lists the observation number and the
|
||||
predicted probability (as Prob or as the variable name specified by the
|
||||
{cmd:generate} option). Values of variables in {it:varlist} will also be
|
||||
specified.
|
||||
|
||||
|
||||
{title:Options}
|
||||
|
||||
{p 4 8 2}{cmd:n(}{it:#}{cmd:)} specifies the number of observations to be listed
|
||||
for each outcome. The default is 5. If multiple observations have the same
|
||||
probabilities, more than the specified number will be listed to include all
|
||||
of them.
|
||||
|
||||
{p 4 8 2}{cmd:generate(}{it:varname}{cmd:)} specifies that the probabilities
|
||||
of observing the outcome value that was observed should be stored in
|
||||
{it:varname}. If not specified, the variable name {cmd:Prob} will be created
|
||||
but dropped after the output is produced.
|
||||
|
||||
{p 4 8 2}[{cmd:no}]{cmd:display} forces the format into {cmd:display} or
|
||||
tabular ({cmd:nodisplay}) format. If you do not specify one of these two
|
||||
options, then Stata chooses one based on its judgment of which would be most
|
||||
readable.
|
||||
|
||||
{p 4 8 2}{cmd:nolabel} causes the numeric codes rather than the label values
|
||||
to be displayed.
|
||||
|
||||
{p 4 8 2}{cmd:noobs} suppresses printing of the observation numbers.
|
||||
|
||||
{p 4 8 2}{cmd:doublespace} produces a blank line between each observation in
|
||||
the listing when in {cmd:nodisplay} mode; it has no effect in {cmd:display}
|
||||
mode.
|
||||
|
||||
|
||||
{title:Examples}
|
||||
|
||||
{p 4 8 2}{cmd:. logit low age lwt race2 race3 smoke ptl ht ui}{p_end}
|
||||
{p 4 8 2}{cmd:. leastlikely}{p_end}
|
||||
{p 4 8 2}{cmd:. leastlikely age lwt, n(10) g(prob)}{p_end}
|
||||
|
||||
|
||||
{title:Author}
|
||||
|
||||
{browse "mailto:jfreese@ssc.wisc.edu":Jeremy Freese}
|
||||
Department of Sociology,
|
||||
University of Wisconsin-Madison
|
117
Modules/ado/plus/l/listblck.ado
Normal file
117
Modules/ado/plus/l/listblck.ado
Normal file
@ -0,0 +1,117 @@
|
||||
*! 1.0.0 10nov1998 Jeroen Weesie/ICS
|
||||
program define listblck
|
||||
version 6
|
||||
local dwidth : set display linesize
|
||||
|
||||
syntax [varlist] [if] [in], [Repeat(int 0) Width(int `dwidth') noObs noLabel]
|
||||
|
||||
* adjust width for displaying the observation numbers
|
||||
if "`obs'" == "" {
|
||||
local replen 3
|
||||
}
|
||||
else {
|
||||
local obs noobs
|
||||
local replen -2
|
||||
}
|
||||
|
||||
* repvar = list of repeated variables
|
||||
* replen = total display width of repeated variables
|
||||
tokenize `varlist'
|
||||
local i 1
|
||||
while `i' <= `repeat' {
|
||||
local repvar "`repvar' `1'"
|
||||
widthvar `1'
|
||||
local replen = `replen' + 2 + r(width)
|
||||
local i = `i'+1
|
||||
mac shift
|
||||
}
|
||||
|
||||
local vlen `replen'
|
||||
local vlist `repvar'
|
||||
|
||||
while "`1'" ~= "" {
|
||||
* ensured that at least one non-repeated variable is displayed!
|
||||
widthvar `1'
|
||||
local len1 = r(width)
|
||||
if `vlen' + 2 + `len1' + 1 >= `dwidth' {
|
||||
* display block
|
||||
* di in gr _dup(`vlen') "-"
|
||||
list `vlist' `in' `if', nodisplay `obs' `label'
|
||||
|
||||
* start new block
|
||||
local vlist "`repvar' `1'"
|
||||
local vlen = `replen' + 2 + `len1'
|
||||
}
|
||||
else {
|
||||
* add `1' to vlist
|
||||
local vlist "`vlist' `1'"
|
||||
local vlen = `vlen' + 2 + `len1'
|
||||
}
|
||||
mac shift
|
||||
}
|
||||
|
||||
* don't forget to display relast block
|
||||
if "`vlist'" ~= "" {
|
||||
*di in gr _dup(`vlen') "-"
|
||||
list `vlist' `in' `if', nodisplay `obs' `label'
|
||||
}
|
||||
|
||||
* clear S_* macros
|
||||
global S_1
|
||||
end
|
||||
|
||||
program define widthvar, rclass
|
||||
args v
|
||||
local f : format `v'
|
||||
local x : display `f' (`v'[1])
|
||||
return scalar width = length("`x'")
|
||||
end
|
||||
exit
|
||||
|
||||
* code for version 5
|
||||
* returns in S_1 the display width of a variable in list-output
|
||||
program define widthvar
|
||||
args var vlab
|
||||
|
||||
local fmt : format `var'
|
||||
local pf = substr("`fmt'",-1,1) /* last char of display format */
|
||||
|
||||
if "`pf'" == "s" {
|
||||
* string
|
||||
local len1 = substr("`fmt'",2,length("`fmt'")-2)
|
||||
}
|
||||
else if "`pf'" == "d" {
|
||||
* date, determine display width of "31 December 1960"
|
||||
local d : display `fmt' 365
|
||||
local len1 = length("`d'")
|
||||
}
|
||||
else {
|
||||
* numeric variable
|
||||
local pp = index("`fmt'", ".")
|
||||
if `pp' > 0 {
|
||||
local len1 = substr("`fmt'",2,`pp'-2)
|
||||
}
|
||||
else local len1 = substr("`fmt'",2,length("`fmt'")-2)
|
||||
|
||||
if "`vlab'" ~= "" {
|
||||
* width is at least 8 if value-labeled
|
||||
local vl : value label `var'
|
||||
if "`vl'" ~= "" { local len1 = max(8,`len1') }
|
||||
}
|
||||
}
|
||||
*global S_1 = max(length("`var'"), `len1')
|
||||
global S_1 `len1'
|
||||
end
|
||||
exit
|
||||
|
||||
Description
|
||||
|
||||
list-like command that repeats list's with blocks of variables rather
|
||||
than wrapping lines or using "display" mode. If the option -repeate-
|
||||
is specified, the first k variable in varlist are repeated in each
|
||||
block.
|
||||
|
||||
Assumptions:
|
||||
list leaves one space after observation numbers
|
||||
list leaves 2 space between variables
|
||||
list does not widen columns for long variables names
|
59
Modules/ado/plus/l/listblck.hlp
Normal file
59
Modules/ado/plus/l/listblck.hlp
Normal file
@ -0,0 +1,59 @@
|
||||
.-
|
||||
help for ^listblck^ [jw] Nov 10, 1998
|
||||
.-
|
||||
|
||||
Block-wise display of values of variables
|
||||
----------------- ------------------------
|
||||
|
||||
^listblck^ [varlist] [^if^ exp] [^in^ range]
|
||||
[^, r^epeat^(^#^) w^idth^(^#^) nol^abel ^noo^bs]
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
^listblck^ is an alternative to ^list^ that displays the values of variables
|
||||
in varlist for selected cases in an "blocks-of-variables" format. If no varlist
|
||||
is specified, the values of all the variables are displayed.
|
||||
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
^repeat(^#^)^ specifies the number of leading variables repeated at the
|
||||
beginning of each block. Defaults to 0.
|
||||
|
||||
^width(^#^)^ specifies the display linesize. By default, ^listblck^ uses the
|
||||
current setting of ^display linesize^.
|
||||
|
||||
^nol^abel causes the numeric codes rather than label values to be displayed.
|
||||
|
||||
^noo^bs suppresses printing of the observation numbers.
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
. ^listblck^
|
||||
. ^listblck make price turn length^
|
||||
. ^listblck make price turn length trunk mpg foreign in 1/20, rep(1)^
|
||||
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
Jeroen Weesie
|
||||
Dept of Sociology
|
||||
Utrecht University
|
||||
J.weesie@@fss.uu.nl
|
||||
|
||||
This project was supported by grant PGS 50-370 of the Netherlands Organization
|
||||
for Scientific Research.
|
||||
|
||||
|
||||
Also See
|
||||
--------
|
||||
|
||||
Manual: ^[R] list^
|
||||
On-line: help on @list@, @listby@, @stlist@, and @xtlist@
|
||||
|
1684
Modules/ado/plus/l/listcoef.ado
Normal file
1684
Modules/ado/plus/l/listcoef.ado
Normal file
File diff suppressed because it is too large
Load Diff
96
Modules/ado/plus/l/listcoef.hlp
Normal file
96
Modules/ado/plus/l/listcoef.hlp
Normal file
@ -0,0 +1,96 @@
|
||||
.-
|
||||
help for ^listcoef^ - 03Nov2005
|
||||
.-
|
||||
|
||||
List transformed regression coefficients and guidelines for interpretation
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
^listcoef^ [varlist], [^pv^alue(#) [^f^actor|^p^ercent|^s^td] ^c^onstant
|
||||
^r^everse ^gt^ ^lt^ ^adj^acent ^nol^abel ^ex^pand ^m^atrix ^h^elp]
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
^listcoef^ lists the estimated coefficients for a variety of regression models.
|
||||
Options allow you to specify different transformations of the coefficients,
|
||||
such as factor change and percent change. Coefficients can be standardized for
|
||||
a unit variance in the independent and/or dependent variables. For ^mlogit^,
|
||||
coefficients for all comparisions among outcomes are included.
|
||||
|
||||
NOTE: For models with categorical outcomes, the output is much clearer if you
|
||||
assign value labels to the dependent variable.
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
^varlist^ indicates that coefficients for only these variables are to be listed
|
||||
If no ^varlist^ is given, coefficients for all variables are listed.
|
||||
|
||||
^pvalue^ specifies that only coefficients with a this significance level or
|
||||
smaller will be printed.
|
||||
|
||||
^factor^ specifies that factor change coefficients should be listed.
|
||||
|
||||
^percent^ specifies that percent change coefficients should be listed.
|
||||
|
||||
^std^ specifies that coefficients standardized to a unit variance for the
|
||||
independent and/or dependent variables should be listed.
|
||||
|
||||
^constant^ includes the constants in the output.
|
||||
|
||||
^reverse^ reverses the comparison implied by the computation of factor or
|
||||
percent change coefficients for ^logit^, ^ologit^, ^clogit^, or ^rologit^;
|
||||
that is, it presents results indicating the change in the odds of b vs. a
|
||||
instead of a vs. b.
|
||||
|
||||
^matrix^ returns results in r() class matrices.
|
||||
|
||||
^help^ includes details on the meaning of each coefficient.
|
||||
|
||||
Options for ^mlogit^ and/or ^slogit^
|
||||
---------------------------------
|
||||
|
||||
^gt^ specifies that only comparisons where the first category has a larger
|
||||
value than the second will be printed (e.g., comparing outcome 2
|
||||
versus 1, but not 1 versus 2).
|
||||
|
||||
^lt^ specifies that only comparisons where the first category has a smaller
|
||||
value than the second will be printed (e.g., comparing outcome 1 versus
|
||||
2, but not 2 versus 1).
|
||||
|
||||
^adjacent^ specifies that only comparisons where the two category values are
|
||||
adjacent will be printed (e.g., comparing outcome 1 versus 2 or 2 versus
|
||||
1, but not 1 versus 3).
|
||||
|
||||
^nolabel^ requests that category numbers rather than value labels be used
|
||||
in the output.
|
||||
|
||||
^expand^ requests expanded output comparing all pairs of outcome categories
|
||||
for ^slogit^.
|
||||
|
||||
Compatable Models
|
||||
-----------------
|
||||
|
||||
^listcoef^ can be used with: ^clogit^, ^cloglog^, ^cnreg^, ^intreg^, ^logistic^, ^logit^,
|
||||
^mlogit^, ^mprobit^, ^nbreg^, ^ologit^, ^oprobit^, ^poisson^, ^probit^, ^regress^, ^rologit^,
|
||||
^slogit^, ^tobit^, ^zinb^, ^zip^, ^ztnb^, and ^ztp^.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
To compute standardized regression coefficients for only those variables that
|
||||
are significant at the .05 level, including the constant:
|
||||
|
||||
. ^regress job fem phd ment fel art cit^
|
||||
. ^listcoef,constant pv(.05)^
|
||||
|
||||
For mlogit, to compute the percentage change in the odds for white with help
|
||||
on the interpretation:
|
||||
|
||||
. ^mlogit occ white ed exp^
|
||||
. ^listcoef white, percent help^
|
||||
|
||||
.-
|
||||
Authors: J. Scott Long and Jeremy Freese
|
||||
www.indiana.edu/~jslsoc/spost.htm
|
||||
spostsup@@indiana.edu
|
744
Modules/ado/plus/l/listutil.hlp
Normal file
744
Modules/ado/plus/l/listutil.hlp
Normal file
@ -0,0 +1,744 @@
|
||||
.-
|
||||
help for various list utilities
|
||||
.-
|
||||
|
||||
Manipulating lists of words
|
||||
---------------------------
|
||||
|
||||
^alphlist^ [ ^, c^apitals ^u^nderscore ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^binolist , k(^#^)^ [ ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^bothlist^ list1 ^\^ list2 [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^choplist^ list ^,^ { ^p^os^(^criterion^)^ | ^l^ength^(^criterion^)^
|
||||
| ^v^alue^(^criterion^)^ | ^c^har^(^#^)^ } [ ^n^oisily ^g^lobal^(^macname(s)^)^ ]
|
||||
|
||||
^collist^ list [ ^, f^ormat^(^format^) nu^mber ]
|
||||
|
||||
^convlist^ numlist1 ^\^ numlist2 [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^cseplist^ list [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^cvarlist^ list ^,^ [ { ^new^ | ^nu^meric | ^s^tring }
|
||||
^n^oisily ^g^lobal^(^macname(s)^)^ ]
|
||||
|
||||
^dellist^ list ^,^ { ^d^elete^(^string^)^ | ^p^os^(^numlist of positions^)^ }
|
||||
[ ^e^xact ^a^ll ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^difflist^ list1 ^\^ list2 [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^eqlist^ list1 ^\^ list2 [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^fmtlist^ list ^, f^ormat^(^format^)^ [ ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^inslist^ list ^, i^nsert^(^words^) p^os^(^numlist of positions^)^
|
||||
[ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^joinlist^ list1 ^\^ list2 [ ^, s^ep ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^lclist^ list [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^maplist^ list ^, m^ap^(^expression^)^ [ ^s^ymbol^(^string^) n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^mnthlist^ [ ^, b^egin^(^str^) n^umber^(^#^) s^tep^(^#^) l^ong ^c^aplc ^u^ppercase
|
||||
^y^ear ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^poslist^ list1 ^\^ list2 [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^postlist^ list ^, p^ost^(^string^)^ [ ^s^ep^ n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^prelist^ list ^, p^re^(^string^)^ [ ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^prodlist^ numlist [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^replist^ list ^, c^opies^(^#^)^ [ ^b^lock ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^revlist^ list [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^rotlist^ list ^, r^ot^(^#^)^ [ ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^sellist^ list ^, s^elect^(^string^)^ [ ^e^xact ^a^ll ^pre^fix ^post^fix ^suf^fix
|
||||
^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^seqlist^ stub ^, c^opies^(^#^)^ [ ^s^tart^(^#^) p^refix ^post^fix^(^string^)^
|
||||
^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^sortlist^ list [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^sublist^ list ^, f^rom^(^string^)^ [ ^t^o^(^string^) all n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^sumlist^ numlist [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^takelist^ list ^, p^os^(^numlist of positions^)^ [ ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^trnclist^ list ^,^ { ^l^ength^(^#^)^ | ^n^umber^(^#^)^ } [ ^n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^uclist^ list [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^uniqlist^ list [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^varflist^ list ^, g^enerate^(^newvar^)^ [ { ^sc^alar | ^g^lobal }
|
||||
^st^ring ^t^ype^(^variable_type^)^ ]
|
||||
|
||||
^vectlist^ vector [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^wclist^ list [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
^xorlist^ list1 ^\^ list2 [ ^, n^oisily ^g^lobal^(^macname^)^ ]
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
^alphlist^ produces the letters of the English alphabet ^a^ ... ^z^ [ ^_^ ]
|
||||
or ^A^ ... ^Z^ [ ^_^] as a list of separate words.
|
||||
|
||||
^binolist^ produces binomial coefficients as a list of separate words.
|
||||
|
||||
^bothlist^ produces the list of words that are in both list1 and list2.
|
||||
Repeated occurrences are selected only once. ^bothlist a b c d \ d e g^
|
||||
produces ^d^.
|
||||
|
||||
^choplist^ chops a list of words into two lists according to a stated
|
||||
criterion.
|
||||
|
||||
^collist^ displays a list in column form: each word is printed starting on
|
||||
a new line.
|
||||
|
||||
^convlist^ produces the convolution of two numlists. Given a_1, ... , a_m
|
||||
and b_1, ... , b_n the convolution is c_k, k = 1, ... , m + n - 1, where c_k
|
||||
is the sum of products a_i * b_j such that i + j - 1 = k. More graphically,
|
||||
consider this table of indexes k for a list of 3 items, indexed by i, and a
|
||||
list of 4 items, indexed by j.
|
||||
|
||||
j
|
||||
1 2 3 4
|
||||
+-----------
|
||||
1 | 1 2 3 4
|
||||
i 2 | 2 3 4 5
|
||||
3 | 3 4 5 6
|
||||
|
||||
In words, form a multiplication table, and take sums over rising
|
||||
diagonals. Thus the convolution of 1 2 1 and 1 3 3 1 is
|
||||
1 (2 + 3) (1 + 6 + 3) (3 + 6 + 1) (3 + 2) 1 = 1 5 10 10 5 1.
|
||||
|
||||
^cseplist^ interpolates commas as separators between words in the list.
|
||||
|
||||
^cvarlist^ selects from a list of words those that are names of variables.
|
||||
|
||||
^dellist^ deletes from a list of words any that contain one or more
|
||||
specified words, or any at specified positions.
|
||||
|
||||
^difflist^ produces a list of words that are in list1 but not in list2.
|
||||
Repeated occurrences are selected only once. ^difflist a b c \ b^
|
||||
produces ^a c^.
|
||||
|
||||
^eqlist^ determines whether two lists are equal, that is, have the
|
||||
same words in the same order.
|
||||
|
||||
^fmtlist^ produces a list of words displayed according to a specified
|
||||
format. Most commonly, this is used for rounding to a specified number
|
||||
of decimal places.
|
||||
|
||||
^inslist^ inserts words in the list at specified positions.
|
||||
|
||||
^joinlist^ joins or juxtaposes corresponding words from two lists. The lists
|
||||
should have equal numbers of words, except that any list of length 1 is
|
||||
repeated to match the other. Given ^a1 a2 a3 \ b1 b2 b3^, ^joinlist^ produces
|
||||
^a1b1 a2b2 a3b3^ by default and ^a1 b1 a2 b2 a3 b3^ with the ^sep^ option.
|
||||
Given ^a1 a2 a3 \ X^, it produces ^a1X a2X a3X^ by default.
|
||||
|
||||
^lclist^ converts each word in the list to lower case.
|
||||
|
||||
^maplist^ evaluates an expression substituting each word in turn. The
|
||||
expression may return a numeric or a string result.
|
||||
|
||||
^mnthlist^ produces a list of months.
|
||||
|
||||
^poslist^ produces a list of positions of words in list1 that are in list2.
|
||||
The position is that of the first occurrence of a word in list2. Words in list2
|
||||
that are not in list1 are assigned position ^0^. ^poslist a b c c d \ b c e^
|
||||
produces ^2 3 0^.
|
||||
|
||||
^postlist^ produces a list of words all followed by the specified string.
|
||||
^postlist a b c, p(70)^ produces ^a70 b70 c70^.
|
||||
|
||||
^prelist^ produces a list of words all preceded by the specified string.
|
||||
^prelist a b c, p(70)^ produces ^70a 70b 70c^.
|
||||
|
||||
^prodlist^ produces the product of a numlist.
|
||||
|
||||
^replist^ replicates a list of words.
|
||||
|
||||
^revlist^ reverses a list of words.
|
||||
|
||||
^rotlist^ rotates a list of words.
|
||||
|
||||
^sellist^ selects from a list of words any that contain one or more specified
|
||||
words.
|
||||
|
||||
^seqlist^ produces by default a list of words suffixed by successive integers,
|
||||
such as stub^1^, stub^2^, ... Note that stub can be blank (an empty string).
|
||||
For further details see under Options.
|
||||
|
||||
^sortlist^ sorts a list of words into alphabetic order.
|
||||
|
||||
^sublist^ removes the string specified by ^from( )^ from each of the
|
||||
words in the list provided. It replaces that string by any string specified
|
||||
by ^to( )^. ^to( )^ defaults to an empty string. If the string specified by
|
||||
^from( )^ is equal to the whole word, it is in effect removed from the list.
|
||||
|
||||
^sumlist^ produces the sum of a numlist.
|
||||
|
||||
^takelist^ yields the words at the specified positions in the list.
|
||||
|
||||
^trnclist^ truncates each word, either so that it is no longer than ^length( )^
|
||||
characters, or so that the last ^number( )^ characters are dropped.
|
||||
|
||||
^uclist^ converts each word in the list to upper case.
|
||||
|
||||
^uniqlist^ deletes from a list of words any but the first occurrence
|
||||
of each word in the list.
|
||||
|
||||
^varflist^ generates a new variable from a list, putting successive words
|
||||
in successive observations, starting at 1.
|
||||
|
||||
^vectlist^ puts the elements of a named vector into a list.
|
||||
|
||||
^wclist^ counts the number of words in a list.
|
||||
|
||||
^xorlist^ selects words that occur in either but not both of two lists
|
||||
(symmetric difference of sets). ^xorlist a b c \ c d e^ selects ^a b d e^.
|
||||
Note that ^xorlist^ yields an empty list if and only if two lists
|
||||
contain the same words (not necessarily in the same order).
|
||||
|
||||
|
||||
Remarks
|
||||
-------
|
||||
|
||||
`Words' are separated by spaces. No significance is attached to the number
|
||||
of spaces. No commas or ^" "^ should be included. In the case of ^bothlist^,
|
||||
^convlist^, ^difflist^, ^eqlist^, ^joinlist^, ^poslist^ and ^xorlist^, ^\^
|
||||
should not be included. Hence ^a b c^ is a list of three words, ^a^, ^b^
|
||||
and ^c^. Similarly, ^1 2 3^ is a list of three words, ^1^, ^2^ and ^3^.
|
||||
|
||||
Position in the list is best explained by example. In the list ^a b c^, the
|
||||
words ^a^, ^b^, ^c^ have positions ^1^, ^2^, ^3^, and also ^-3^, ^-2^, ^-1^. Thus
|
||||
negative positions are counted backwards from the end of the list and
|
||||
position ^-1^ refers to the last word. It is not an error to refer to
|
||||
position ^0^ but the result is empty.
|
||||
|
||||
^choplist^ with ^length( )^ or ^char( )^, ^dellist, delete( )^, ^eqlist^, ^lclist^,
|
||||
^sellist^, ^sortlist^, ^sublist^, ^trnclist^, ^uclist^ and ^varflist^ cannot
|
||||
handle lists containing any individual word longer than 80 characters.
|
||||
|
||||
^maplist^ may produce undesired results if expressions returning string
|
||||
results contain or would return any strings longer than 80 characters.
|
||||
Expressions are not currently checked for this problem.
|
||||
|
||||
Any list given as input may be specified by one or more local or global
|
||||
macros.
|
||||
|
||||
The list might be a list of variable names, for example, but note that
|
||||
these programs do not treat wild cards or dashes in variable lists in
|
||||
any special way. Similarly, as a general rule, these programs do not
|
||||
expand number lists (numlists) given as the main argument. Exceptions
|
||||
are ^convlist^, ^prodlist^ and ^sumlist^.
|
||||
|
||||
A word contains a string if ^index("^word^","^string^") > 0^.
|
||||
|
||||
^wclist^ allows two statements of the form
|
||||
|
||||
^local nw : word count^ list
|
||||
^di `nw'^
|
||||
|
||||
to be replaced by one statement.
|
||||
|
||||
^lclist^ and ^uclist^ are needed for lists more than 80 characters long,
|
||||
because, for example, ^local lower = lower("^string^")^ truncates strings
|
||||
that long. However, for the same reason, ^lclist^ and ^uclist^ cannot handle
|
||||
individual words more than 80 characters long. Naturally, this is less
|
||||
of a restriction.
|
||||
|
||||
|
||||
Options
|
||||
-------
|
||||
|
||||
- options for all commands except ^collist^ and ^varflist^
|
||||
|
||||
^noisily^ specifies that the resulting list(s) should be displayed.
|
||||
|
||||
^global( )^ specifies a global macro name to hold the resulting list.
|
||||
|
||||
However, the ^global^ option of ^choplist^ and ^cvarlist^ may contain either
|
||||
one or two names. The first name (of either one or two) will be used to hold
|
||||
the words selected by the stated criterion. Any second name will be used to
|
||||
hold the words not selected.
|
||||
|
||||
Note that the ^global^ option of ^varflist^, which does not take
|
||||
an argument, has a different function.
|
||||
|
||||
- options specific to ^alphlist^
|
||||
|
||||
^capitals^ specifies that the list should be ^A^ ... ^Z^ rather than the
|
||||
default ^a^ ... ^z^.
|
||||
|
||||
^underscore^ adds ^_^ to the list.
|
||||
|
||||
- option specific to ^binolist^
|
||||
|
||||
^k(^#^)^ specifies that the binomal coefficients should be ^comb(^k - 1, i - 1^)^
|
||||
for i = 1, ... , k and integer k >= 1. ^k(5)^ produces ^1 4 6 4 1^. It is a
|
||||
required option.
|
||||
|
||||
- options specific to ^choplist^
|
||||
|
||||
^pos( )^ specifies a criterion for selecting words according to their
|
||||
positions. ^pos(<=3)^ puts the first three words in list 1, and any others
|
||||
in list 2.
|
||||
|
||||
^length( )^ specifies a criterion for selecting words according to their
|
||||
lengths. ^length(7)^ puts words of length <= 7 in list 1, and any others in
|
||||
list 2.
|
||||
|
||||
^value( )^ specifies a criterion for selecting words according to their
|
||||
values. Words may be compared according to their numeric or string order.
|
||||
|
||||
^char(^#^)^ specifies that the first # characters of each word be selected.
|
||||
^char(1)^ puts the first character of each word in list 1, and any others
|
||||
in list 2. If # is negative, the last # characters of each word will be
|
||||
selected. ^char(-1)^ puts the last character of each word in list 1, and
|
||||
any others in list 2. Note that list 1 and list 2 will contain the same
|
||||
number of words if and only if every word is at least two characters long.
|
||||
|
||||
Precisely one of ^pos( )^, ^length( )^, ^value( )^ or ^char( )^ should be
|
||||
specified. With the first three options, if just a number is specified,
|
||||
^<=^ is prefixed, except that with ^pos( )^ if a negative sign is detected,
|
||||
^>=^ is prefixed. ^pos(3)^ and ^pos(<=3)^ are thus equivalent, as are
|
||||
similar choices with ^length( )^ and ^value( )^. ^pos(-1)^ puts the last
|
||||
word in list 1, and all others in list 2.
|
||||
|
||||
- options specific to ^collist^
|
||||
|
||||
^format( )^ specifies a format to use for each word. See help for @format@.
|
||||
|
||||
^number^ specifies that words should be numbered from 1 upwards.
|
||||
|
||||
- options specific to ^cvarlist^
|
||||
|
||||
^new^, ^numeric^ and ^string^ specify that words are to be selected if they
|
||||
are the names of new, numeric or string variables respectively. Only one
|
||||
of these options may be specified. Otherwise the names of variables in
|
||||
memory will be selected.
|
||||
|
||||
- options specific to ^dellist^
|
||||
|
||||
^delete(^string^)^ specifies the words to be deleted. By default a word in
|
||||
the list is deleted if it contains any of the words in ^delete( )^. Thus
|
||||
^dellist abc bcd c d e, d(a b c)^ deletes ^abc bcd c^.
|
||||
|
||||
^all^ specifies that to be deleted each word must contain all the words
|
||||
in ^delete( )^. Thus ^dellist abc bcd c d e, d(a b c) all^ deletes ^abc^.
|
||||
|
||||
^exact^ specifies that exact matches are required. Words will be deleted
|
||||
only if they equal the specified word.
|
||||
|
||||
^all^ may not be specified with ^exact^.
|
||||
|
||||
^pos( )^ should contain a numlist of positions of words to be deleted.
|
||||
|
||||
Either ^delete( )^ or ^pos( )^ must be specified.
|
||||
|
||||
- option specific to ^fmtlist^
|
||||
|
||||
^format(^format^)^ specifies a format. It is a required option.
|
||||
See help for @format@.
|
||||
|
||||
- options specific to ^inslist^
|
||||
|
||||
^inslist^ inserts words from ^insert( )^ as separate words at positions
|
||||
in the original list given by ^pos( )^.
|
||||
|
||||
^insert( )^ should contain one or more space-separated words.
|
||||
|
||||
^pos( )^ should contain a numlist of positions. Position # means after word #
|
||||
in the original list or before word # + 1. Thus ^0^ means before word 1, ^1^ means
|
||||
after word 1, and ^-1^ means after the last word. Numbers may be repeated.
|
||||
|
||||
If the number of words in ^insert( )^ is less than the number
|
||||
of positions, ^insert( )^ is expanded as required.
|
||||
|
||||
For example, ^inslist a b c d e f g h , i(x) p(1/7)^ produces
|
||||
|
||||
^a x b x c x d x e x f x g x h^
|
||||
|
||||
while ^inslist a b c d e f g h , i(( )) p(0 4 4 8)^ produces
|
||||
|
||||
^( a b c d ) ( e f g h)^
|
||||
|
||||
- option specific to ^joinlist^
|
||||
|
||||
^sep^ specifies that words produced are to be separate, that is,
|
||||
juxtaposed not joined.
|
||||
|
||||
- options specific to ^maplist^
|
||||
|
||||
^map(^expression^)^ specifies an expression which is evaluated using each word
|
||||
in turn. It is a required option. The expression may return either a numeric
|
||||
or a string result. The expression must contain a particular symbol (default
|
||||
^@@^) which is used as a placeholder for the word. Thus ^map(-@@)^ negates each
|
||||
word; ^map(sqrt(@@))^ calculates the square root of each word; ^map("foo @@")^
|
||||
interpolates ^foo^ as a separate word before each word in the list.
|
||||
|
||||
^symbol(^string^)^ specifies an alternative to ^@@^ as a placeholder for
|
||||
each word. Thus ^map(sqrt(X)) sy(X)^ is equivalent to ^map(sqrt(@@))^.
|
||||
|
||||
- options specific to ^mnthlist^
|
||||
|
||||
^begin(^str^)^ specifies a month to start the sequence. str can be an integer
|
||||
between 1 and 12, indicating a month from January (1) to December (12), or
|
||||
an unambiguous English month name or abbreviation (case is not important).
|
||||
Thus a string starting with any of "ja", "Ja", "JA", or "jA" is taken to mean
|
||||
January. January is the default.
|
||||
|
||||
^number(^#^)^ specifies the number of months in the list. 12 is the default.
|
||||
|
||||
^step(^#^)^ specifies the step between successive months in the list.
|
||||
1 is the default.
|
||||
|
||||
^long^ indicates long names (january ... december or January ... December).
|
||||
Three letter abbreviations jan ... dec are the default.
|
||||
|
||||
^caplc^ indicates an initial capital followed by lower case, as in January ...
|
||||
December or Jan ... Dec. All lower case is the default.
|
||||
|
||||
^uppercase^ indicates all upper case, as in JANUARY ... DECEMBER or
|
||||
JAN ... DEC. All lower case is the default.
|
||||
|
||||
^year^ indicates the year in which in the first month occurs. Years will
|
||||
be appended to each month.
|
||||
|
||||
Thus ^mnthlist^ produces ^jan feb mar apr may jun jul aug sep oct nov dec^.
|
||||
|
||||
^mnthlist, n(49) b(3) s(12) year(1952) caplc^ produces the 49 months
|
||||
^Mar1952 Mar1953^ ... ^Mar1999 Mar2000^.
|
||||
|
||||
- options specific to ^postlist^
|
||||
|
||||
^post(^string^)^ specifies the string to be postfixed. It is a required
|
||||
option.
|
||||
|
||||
^sep^ specifies that whatever is postfixed by ^postlist^ is a separator
|
||||
and should not appear after the last word in the list.
|
||||
^postlist a b c, p(,) sep^ produces the list ^"a, b, c"^.
|
||||
|
||||
- option specific to ^prelist^
|
||||
|
||||
^pre(^string^)^ specifies the string to be prefixed. It is a required
|
||||
option.
|
||||
|
||||
- options specific to ^replist^
|
||||
|
||||
^copies(^#^)^ specifies the number of copies to be produced.
|
||||
By itself ^copies(3)^ produces ^a a a b b b c c c^ given ^a b c^.
|
||||
It is a required option.
|
||||
|
||||
^block^ specifies that the list is to be replicated as a block.
|
||||
^copies(3) block^ produces ^a b c a b c a b c^ given ^a b c^.
|
||||
|
||||
- option specific to ^rotlist^
|
||||
|
||||
^rot(^#^)^ rotates the list as follows. Suppose there are n words in the
|
||||
list and ^rot(^r^)^ is specified. If r >= 0, the new list is the last n - r
|
||||
words of the list followed by the first r words: that is, r words from
|
||||
the start of the list are moved to the end. If r < 0, the new list is the
|
||||
last r words of the list followed by the first n - r words: that is, r words
|
||||
from the end of the list are moved to the start. Thus given ^1 2 3 4 5^,
|
||||
^rot(1)^ produces ^2 3 4 5 1^ and ^rot(-1)^ produces ^5 1 2 3 4^. For any
|
||||
integer r, ^mod(^r^,^n^)^ is used.
|
||||
|
||||
- options specific to ^sellist^
|
||||
|
||||
^select(^string^)^ specifies the words to be selected. It is a required
|
||||
option. By default a word in the list is selected if it contains any
|
||||
of the words in ^select( )^. Thus ^sellist abc bcd c d e, s(a b c)^
|
||||
produces ^abc bcd c^. With any of ^prefix^, ^postfix^ or ^suffix select( )^
|
||||
must contain only a single word.
|
||||
|
||||
^exact^ specifies that exact matches are required. Words will be selected
|
||||
only if they equal the specified word.
|
||||
|
||||
^all^ specifies that to be selected each word must contain all the words
|
||||
in ^select^. Thus ^sellist abc bcd c d e, s(a b c) all^ produces ^abc^.
|
||||
|
||||
^all^ may not be specified with ^exact^.
|
||||
|
||||
^prefix^ specifies that to be selected each word must contain the single
|
||||
word in ^select( )^ as a prefix, at its start.
|
||||
Thus ^sellist abc bcd c d e, s(c) pre^ produces ^c^.
|
||||
|
||||
^postfix^ or ^suffix^ specifies that to be selected each word must contain
|
||||
the single word in ^select( )^ as a postfix or suffix, at its end.
|
||||
Thus ^sellist abc bcd c d e, s(c) post^ produces ^abc c^.
|
||||
|
||||
^prefix^ may not be combined with ^postfix^ or ^suffix^. None of these options
|
||||
may be combined with ^exact^ or ^all^.
|
||||
|
||||
- options specific to ^seqlist^
|
||||
|
||||
^copies(^#^)^ specifies the number of words in the list to be produced.
|
||||
By itself ^copies(3)^ produces stub^1^ stub^2^ stub^3^. It is a required
|
||||
option.
|
||||
|
||||
^start(^#^)^ specifies a starting number other than 1. ^copies(3) start(3)^
|
||||
produces stub^3^ stub^4^ stub^5^.
|
||||
|
||||
^prefix^ specifies that numbers are to be attached as prefixes.
|
||||
^copies(3) prefix^ produces ^1^stub ^2^stub ^3^stub.
|
||||
|
||||
^postfix(^string^)^ specifies a postfix to be added to all words.
|
||||
^post(b)^ adds ^b^ to the end of each word.
|
||||
|
||||
- options specific to ^sublist^
|
||||
|
||||
^from(^string^)^ specifies the string to be substituted. It is a required
|
||||
option.
|
||||
|
||||
^to(^string^)^ optionally specifies a replacement string to be used by
|
||||
^sublist^. In other words, it defaults to an empty string, and in that case
|
||||
^sublist^ deletes the argument of ^from( )^ from each word in the list
|
||||
without replacing it.
|
||||
|
||||
^all^ specifies that all occurrences of string in each word are to
|
||||
be substituted by ^sublist^. The default is to substitute the first
|
||||
occurrence only.
|
||||
|
||||
- option specific to ^takelist^
|
||||
|
||||
^pos(^numlist of positions^)^ specifies the positions of the words to be taken
|
||||
from the list.
|
||||
|
||||
- options specific to ^trnclist^
|
||||
|
||||
^length(^#^)^ specifies the maximum length of word acceptable. With
|
||||
^length(8)^, for example, words of 8 or fewer characters are unchanged,
|
||||
while words of 9 or more characters are truncated to the first 8
|
||||
characters.
|
||||
|
||||
^number(^#^)^ specifies the number of characters to be dropped from the
|
||||
end of each word. ^number(^1^)^ drops the last character from each word.
|
||||
Dropping # characters from a word # or fewer characters long blanks it out.
|
||||
|
||||
- options specific to ^varflist^
|
||||
|
||||
^generate(^newvar^)^ specifies the name of a new variable to receive
|
||||
values. It is a required option.
|
||||
|
||||
^global^ indicates that the list is of global names, whose values are to be
|
||||
put in the new variable. ^varflist a b c, g(foo) global^ is equivalent to
|
||||
^varflist $a $b $c, g(foo)^. Conversely, to put the names of globals ^a b c^
|
||||
in a new variable, do not specify ^global^.
|
||||
|
||||
^scalar^ indicates that the list is of scalar names, whose values are to be
|
||||
put in the new variable. ^varflist a b c, g(foo) scalar^ puts the values of
|
||||
scalars with names ^a b c^ in ^foo^. Conversely, to put the names of scalars
|
||||
^a b c^ in a new variable, do not specify ^scalar^.
|
||||
|
||||
^global^ and ^scalar^ may not be combined.
|
||||
|
||||
^string^ specifies that the new variable is to be a string variable.
|
||||
^string^ without ^type( )^ implies ^str1^, so that ^type( )^ is not required
|
||||
with ^string^. However, a numeric data type must not be specified with
|
||||
^string^.
|
||||
|
||||
^type(^variable_type^)^ specifies the type as which the new variable is
|
||||
first created. See ^string^ above.
|
||||
|
||||
|
||||
Saved results
|
||||
-------------
|
||||
|
||||
Note that, except for ^collist^ and ^varflist^, in each case global macros may
|
||||
also be set using ^global( )^.
|
||||
|
||||
^alphlist^: ^r(list)^ contains a set of letters of the alphabet as separate
|
||||
words.
|
||||
|
||||
^binolist^: ^r(list)^ contains binomial coefficients as separate words.
|
||||
|
||||
^bothlist^: ^r(list)^ contains the intersection, those words in list1 and
|
||||
in list2.
|
||||
|
||||
^choplist^: ^r(list1)^ contains the words selected by the stated criterion.
|
||||
^r(list2)^ contains the words not selected.
|
||||
|
||||
^collist^ : none.
|
||||
|
||||
^convlist^: ^r(list)^ contains the convolution of the two numlists
|
||||
supplied.
|
||||
|
||||
^cseplist^: ^r(list)^ contains the words of the original list separated by
|
||||
commas. ^cseplist 1 2 3 4 5^ returns ^1,2,3,4,5^ as its result.
|
||||
|
||||
^cvarlist^: ^r(list1)^ contains the words that are variable names.
|
||||
^r(list2)^ contains the words that are not.
|
||||
|
||||
^dellist^: ^r(list)^ contains the original list minus those words deleted.
|
||||
|
||||
^difflist^: ^r(list)^ contains the difference set, those words in list1 not
|
||||
in list2.
|
||||
|
||||
^eqlist^: ^r(iseq)^ is 1 if list1 and list2 are equal and 0 otherwise.
|
||||
|
||||
^fmtlist^: ^r(list)^ contains the list of words displayed using the specified
|
||||
format.
|
||||
|
||||
^inslist^: ^r(list)^ contains the list after insertion.
|
||||
|
||||
^joinlist^: ^r(list)^ contains the list of joined or juxtaposed words.
|
||||
|
||||
^lclist^: ^r(list)^ contains the list in lower case.
|
||||
|
||||
^maplist^: ^r(list)^ contains the results of evaluating the expression
|
||||
supplied with each word substituted in turn.
|
||||
|
||||
^mnthlist^: ^r(list)^ contains the list of months specified.
|
||||
|
||||
^poslist^: ^r(list)^ contains the indexes of the words in list2 within list1.
|
||||
|
||||
^postlist^: ^r(list)^ contains the original list with each word followed by
|
||||
the specified string (unless the ^sep^ option is specified).
|
||||
|
||||
^prelist^: ^r(list)^ contains the original list with each word preceded by
|
||||
the specified string.
|
||||
|
||||
^prodlist^: ^r(prod)^ contains the product of the list.
|
||||
|
||||
^replist^: ^r(list)^ contains the replicated list.
|
||||
|
||||
^revlist^: ^r(list)^ contains the reverse of the original list (last word
|
||||
first, etc.)
|
||||
|
||||
^rotlist^: ^r(list)^ contains the rotated list.
|
||||
|
||||
^sellist^: ^r(list)^ contains those words selected from the original list.
|
||||
|
||||
^seqlist^: ^r(list)^ contains a list of words suffixed (optionally, prefixed)
|
||||
by successive integers.
|
||||
|
||||
^sortlist^: ^r(list)^ contains the words from list sorted into alphabetic order.
|
||||
|
||||
^sublist^: ^r(list)^ contains the original list with each word modified by
|
||||
substitution of the argument of ^to( )^ for the argument of ^from( )^.
|
||||
|
||||
^sumlist^: ^r(sum)^ contains the sum of the list.
|
||||
|
||||
^takelist^: ^r(list)^ contains words which were at specified positions in the
|
||||
list.
|
||||
|
||||
^trnclist^: ^r(list)^ contains the original list, except that either each word
|
||||
more than ^length( )^ characters long is truncated to its first ^length( )^
|
||||
characters, or the last ^number( )^ characters have been dropped.
|
||||
|
||||
^uclist^: ^r(list)^ contains the list in upper case.
|
||||
|
||||
^uniqlist^: ^r(list)^ contains the first occurrence of each word from list.
|
||||
|
||||
^varflist^: none.
|
||||
|
||||
^vectlist^: ^r(list)^ contains the elements of a vector as a list of words.
|
||||
|
||||
^wclist^: ^r(nw)^ contains the number of words in list.
|
||||
|
||||
^xorlist^: ^r(list)^ contains the symmetric difference set, those words in
|
||||
either list1 or list2, but not both.
|
||||
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
. ^binolist, k(5)^
|
||||
|
||||
. ^choplist 1 2 3 4 5 6 7, p(<=3)^
|
||||
. ^choplist 1 2 3 4 5 6 7, p(3)^
|
||||
. ^choplist 7 6 5 4 3 2 1, v(>=3)^
|
||||
. ^choplist 7 6 5 4 3 2 1, v(3)^
|
||||
|
||||
any variable names of 8 characters, which cannot be lengthened
|
||||
in Stata 6?
|
||||
|
||||
. ^unab list : _all^
|
||||
. ^choplist `list', l(==8) n^
|
||||
. ^choplist `list', l(==8) g(eightch)^
|
||||
|
||||
^$eightch^ will hold all names 8 characters long.
|
||||
|
||||
. ^ds2^
|
||||
. ^sellist `r(varlist)', s(age)^
|
||||
. ^local age `r(list)'^
|
||||
. ^l `age'^
|
||||
. ^su `age'^
|
||||
|
||||
. ^ds2^
|
||||
. ^sellist `r(varlist)', s(age)^
|
||||
. ^sortlist `r(list)'^
|
||||
. command ^`r(list)'^
|
||||
|
||||
. ^maplist 1 2 3 4 5, m(sqrt(@@))^
|
||||
. ^fmtlist `r(list)', f(%4.3f)^
|
||||
|
||||
every 1 April for 20 years:
|
||||
. ^mnthlist, n(20) b(4) y(1981) s(12)^
|
||||
. ^maplist `r(list)', map(d(1@@))^
|
||||
. ^graph price date, xla(`r(list)')^
|
||||
|
||||
. ^local list inc exp profit^
|
||||
. ^postlist `list', post(70)^
|
||||
. ^for var `list' \ new `r(list)' : rename X Y^
|
||||
|
||||
. ^seqlist a, c(10)^
|
||||
|
||||
chances of k (1 <= k <= 20) heads in a row:
|
||||
. ^seqlist , c(20) n^
|
||||
. ^maplist `r(list)' , map(0.5^^@@) n^
|
||||
|
||||
instead of
|
||||
. ^graph using l1g1 l1g2 l1g3 l1g4 l1g5 l1g6 l1g7 l1g8 l1g9 l1g10^
|
||||
type
|
||||
. ^seqlist l1g, c(10)^
|
||||
. ^graph using `r(list)'^
|
||||
|
||||
to put a set of scalar names and corresponding values in a variable:
|
||||
. ^varflist a b c d e f g h, gen(names) string^
|
||||
. ^varflist a b c d e f g h, gen(values) scalar type(double)^
|
||||
|
||||
to put a little data set in a variable:
|
||||
. ^varflist -1 0 1 2.71828 3.1459 42, gen(data)^
|
||||
|
||||
|
||||
Acknowledgements
|
||||
----------------
|
||||
|
||||
This set of programs has benefitted from questions and comments from
|
||||
several members of Statalist, especially Kit Baum, for encouragement
|
||||
and suggestions; Austin Frakt, for unearthing an important bug; and
|
||||
Fred Wolfe, who provided the stimulus to extend ^dellist^ and ^sellist^.
|
||||
|
||||
|
||||
Author
|
||||
------
|
||||
|
||||
Nicholas J. Cox, University of Durham, U.K.
|
||||
n.j.cox@@durham.ac.uk
|
||||
|
||||
|
||||
Also see
|
||||
--------
|
||||
|
||||
On-line: help for @format@, @numlist@, @nlist@, @unab@, @ds2@ (if installed),
|
||||
@vallist@ (if installed)
|
||||
Manual: ^[U] 21.3 Macros^, ^[R] unab^
|
||||
|
||||
|
||||
|
175
Modules/ado/plus/l/log2html.ado
Normal file
175
Modules/ado/plus/l/log2html.ado
Normal file
@ -0,0 +1,175 @@
|
||||
*! log2html 1.2.9 cfb/njc/br 08jun2006
|
||||
*! log2html 1.2.8 cfb/njc/br 09feb2005
|
||||
*! log2html 1.2.7 cfb/njc/br 12oct2004
|
||||
*! log2html 1.2.6 cfb/njc/br 2oct2003
|
||||
*! log2html 1.2.5 cfb/njc/br 17Jun2003
|
||||
*! log2html 1.2.0 cfb/njc 3Mar2003
|
||||
*! log2html 1.1.1 cfb/njc 17Dec2001
|
||||
program log2html
|
||||
version 8.0
|
||||
syntax anything(name=smclfile id="The name of a .smcl logfile is") ///
|
||||
[, ERASE replace TItle(str) INput(str) Result(str) BG(str) LINEsize(integer `c(linesize)') ///
|
||||
TExt(str) ERRor(str) PERcentsize(integer 100) BOLD CSS(str) SCHeme(str)]
|
||||
|
||||
// syntax processing
|
||||
|
||||
if "`css'" != "" & `"`input'`result'`text'`error'`bg'`scheme'"' != "" {
|
||||
di as err "if CSS is specified, you may not specify any colors"
|
||||
exit 198
|
||||
}
|
||||
|
||||
if "`scheme'" != "" {
|
||||
if `"`input'`result'`text'`error'`bg'"' != "" {
|
||||
di as err ///
|
||||
"if a scheme is specified, you may not specify any colors"
|
||||
exit 198
|
||||
}
|
||||
|
||||
local names "bg input result text error"
|
||||
local cblack "000000 ffffff ffff00 00ff00 ff0000"
|
||||
local cwhite "ffffff 000000 000000 000000 ff0000"
|
||||
local cblue "000090 ffffff ffff00 00ff00 ff0000"
|
||||
local cugly "ff00ff 9999ff ff99ff 00ff00 cccc00"
|
||||
local cyellow "ffffcc cc00cc 0000cc 000000 ff0000"
|
||||
|
||||
local cnt 1
|
||||
foreach name of local names {
|
||||
local `name' : word `cnt++' of `c`scheme''
|
||||
}
|
||||
if "`bg'"=="" {
|
||||
display as error "scheme `scheme' does not exist! Available schemes are "
|
||||
display as error " black, white, blue, and yellow."
|
||||
exit 198
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
if "`input'" == "" local input "CC6600"
|
||||
if "`result'" == "" local result "000099"
|
||||
if "`text'" == "" local text "000000"
|
||||
if "`error'" == "" local error "dd0000"
|
||||
if "`bg'" == "" local bg "ffffff"
|
||||
else {
|
||||
if "`bg'" == "gray" | "`bg'" == "grey" {
|
||||
local bg "cccccc"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !inrange(`linesize', 40, 255) {
|
||||
display as err "linesize must be between 40 and 255"
|
||||
exit 125
|
||||
}
|
||||
|
||||
if `percentsize' <= 0 {
|
||||
display as err "percentsize() must be a positive integer"
|
||||
exit 198
|
||||
}
|
||||
|
||||
// filenames and handles
|
||||
|
||||
tempname hi ho
|
||||
tempfile htmlfile
|
||||
local origfile `smclfile'
|
||||
if (!index(lower("`origfile'"),".smcl")) {
|
||||
local origfile "`origfile'.smcl"
|
||||
}
|
||||
local smclfile : subinstr local smclfile ".smcl" ""
|
||||
local smclfile : subinstr local smclfile ".SMCL" ""
|
||||
local smclfile : subinstr local smclfile `"""' "", all /* '"' (for fooling emacs) */
|
||||
local smclfile : subinstr local smclfile "`" "", all
|
||||
local smclfile : subinstr local smclfile "'" "", all
|
||||
local outfile `"`smclfile'.html"'
|
||||
local ll "ll(`linesize')"
|
||||
qui log html `"`origfile'"' `"`htmlfile'"', `replace' yebf whbf `ll'
|
||||
|
||||
// line-by-line processing
|
||||
|
||||
file open `hi' using `"`htmlfile'"', r
|
||||
file open `ho' using `"`outfile'"', w `replace'
|
||||
file write `ho' _n
|
||||
file write `ho' "<html>" _n "<head>" _n
|
||||
if `"`title'"' ~= "" {
|
||||
file write `ho' `"<title>`title'</title>"' _n
|
||||
}
|
||||
file write `ho' `"<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">"' _newline
|
||||
file write `ho' `"<meta http-equiv="Content-Style-Type" content="text/css">"' _newline
|
||||
if "`css'" == "" {
|
||||
file write `ho' `"<style type="text/css">"' _newline
|
||||
file write `ho' "BODY{background-color: `bg';" _newline
|
||||
file write `ho' `" font-family: monaco, "courier new", monospace;"' _newline
|
||||
if `percentsize' != 100 {
|
||||
file write `ho' "font-size:`percentsize'%;" _newline
|
||||
}
|
||||
file write `ho' " color: #`text'}" _newline
|
||||
if "`bold'" != "" {
|
||||
file write `ho' ".input, .result, .error{font-weight: bold}" _newline
|
||||
}
|
||||
file write `ho' ".input, .result, .error{font-family: Verdana, sans-serif}" _newline
|
||||
file write `ho' ".input {color: #`input'}" _newline
|
||||
file write `ho' ".result{color: #`result'}" _newline
|
||||
file write `ho' ".error{color: #`error'}" _newline
|
||||
file write `ho' "</style>" _newline
|
||||
}
|
||||
else {
|
||||
file write `ho' `"<link rel="stylesheet" href="`css'">"' _newline
|
||||
}
|
||||
file write `ho' "</head>" _newline
|
||||
file write `ho' "<body>" _newline
|
||||
if `"`title'"' != "" {
|
||||
file write `ho' `"<h2>`title'</h2>"' _n
|
||||
}
|
||||
|
||||
file read `hi' line
|
||||
|
||||
local cprev = 0
|
||||
|
||||
while r(eof) == 0 {
|
||||
|
||||
// change <p> (which should be a div) to a <br><br>
|
||||
local line : ///
|
||||
subinstr local line "<p>" "<br><br>", all
|
||||
|
||||
local line: ///
|
||||
subinstr local line "<b>. " "<span class=input>. ", count(local c)
|
||||
|
||||
// catch continuation lines
|
||||
local word1 : word 1 of `"`line'"'
|
||||
if substr(`"`word1'"',1,7) == "<b>>" & `cprev' {
|
||||
local line : ///
|
||||
subinstr local line "<b>" "<span class=input>", count(local c)
|
||||
}
|
||||
else {
|
||||
local line: ///
|
||||
subinstr local line "<b>" "<span class=result>", all
|
||||
}
|
||||
|
||||
*local line : subinstr local line "---" "___", all
|
||||
local line: subinstr local line "</b>" "</span>", all
|
||||
|
||||
// check for error number
|
||||
if substr(`"`word1'"',1,2) == "r(" {
|
||||
if real(substr(`"`word1'"',3,index(`"`word1'"',")")-3)) < . {
|
||||
local line `"<div class=error> `line' </div>"'
|
||||
}
|
||||
}
|
||||
local tmp=substr("`line'",1,18)
|
||||
di "first character : `tmp'"
|
||||
if "`tmp'"!="<span class=input>" {
|
||||
file write `ho' `"`macval(line)'"' _n
|
||||
}
|
||||
local cprev = `c'
|
||||
file read `hi' line
|
||||
}
|
||||
|
||||
file write `ho' "</body>" _n "</html>" _n
|
||||
file close `ho'
|
||||
|
||||
di _n `"HTML log file `outfile' created"'
|
||||
if "`erase'" ~= "" {
|
||||
erase `"`origfile'"'
|
||||
}
|
||||
end
|
||||
|
||||
|
182
Modules/ado/plus/l/log2html.hlp
Normal file
182
Modules/ado/plus/l/log2html.hlp
Normal file
@ -0,0 +1,182 @@
|
||||
{smcl}
|
||||
{* 8jun2006}{...}
|
||||
{hline}
|
||||
help for {hi:log2html}{right:SSC distribution 8 June 2006}
|
||||
{hline}
|
||||
|
||||
{title:Translate a SMCL log file into HTML}
|
||||
|
||||
{p 8 17 2}{cmd:log2html}
|
||||
{it:smclfile}
|
||||
[{cmd:,}
|
||||
{cmd:replace}
|
||||
{cmd:erase}
|
||||
{cmdab:ti:tle}{cmd:(}{it:string}{cmd:)}
|
||||
{cmdab:line:size(}{it:#}{cmd:)}{break}
|
||||
{cmdab:per:centsize(}{it:integer}{cmd:)}
|
||||
{cmd:bold}{break}
|
||||
{cmdab:sch:eme}{cmd:(}{it:string}{cmd:)}
|
||||
{cmd:css(}{it:string}{cmd:)}{break}
|
||||
{cmdab:in:put}{cmd:(}{it:string}{cmd:)}
|
||||
{cmdab:r:esult}{cmd:(}{it:string}{cmd:)}
|
||||
{cmdab:err:or}{cmd:(}{it:string}{cmd:)}
|
||||
{cmdab:te:xt}{cmd:(}{it:string}{cmd:)}
|
||||
{cmd:bg(}{it:string}{cmd:)}
|
||||
]
|
||||
|
||||
|
||||
{title:Description}
|
||||
|
||||
{p 4 4 2}{cmd:log2html} translates Stata log files or other
|
||||
files in SMCL to HTML.
|
||||
|
||||
{title:Remarks}
|
||||
|
||||
{p 4 4 2}{cmd:log2html} is primarily for use after {cmd:log}; see {help log}.
|
||||
|
||||
{p 4 4 2}{cmd:log2html} makes use of an undocumented command in Stata version 7
|
||||
up, {cmd:log html}, which generates HTML files from SMCL (e.g. log) files.
|
||||
SMCL, the Stata Markup and Control Language {help smcl}, is the default log
|
||||
file format introduced with version 7, and contains markup (similar to HTML)
|
||||
around elements of the log file. To use {cmd:log2html} on log files, you must
|
||||
first generate the default SMCL log file, not a text log file, with the file
|
||||
extension {cmd:.smcl}. Thus if you have {cmd:set logtype text} to prevent the
|
||||
generation of SMCL log files, you must either turn it off or explicitly state
|
||||
that a SMCL log file is to be produced, as by {cmd: log using my.smcl}.
|
||||
|
||||
{p 4 4 2}{cmd:log2html} requires only the base name of a logfile:
|
||||
e.g. {cmd:my}, if the logfile is named {cmd:my.smcl}. The name of the HTML file
|
||||
produced will be this base name with {cmd:.html} appended, e.g. {cmd:my.html}.
|
||||
|
||||
{p 4 4 2}{cmd:log2html} requires Stata version 8 at least.
|
||||
|
||||
{p 4 4 2}{cmd:loghtml} produces a complete HTML page (i.e. with <HTML> and
|
||||
<BODY> tags). By default, the page will have a white background; input lines
|
||||
(those resulting from user input) are rendered in RGB color "CC6600" (a shade
|
||||
of brown); and highlighted result-window lines are rendered in RGB color
|
||||
"000099" (a shade of blue). The options permit other choices for these three
|
||||
colors. For best results, one of the 216 "web safe" colors that display
|
||||
properly in web browsers on all computers in 256-color mode should be used.
|
||||
Also note that some combinations of colors are not workable; e.g. a black
|
||||
("000000") background will cause all normally-rendered text to disappear.
|
||||
|
||||
{p 4 4 2}Colors are specified as hexadecimal RGB colors ranging from 000000
|
||||
(black) to FFFFFF (white), where FF0000 is red, 00FF00 is green, and 0000FF is
|
||||
blue. It is best to use web-safe colors, where both digits of each color pair
|
||||
match and are divisible by 3 (i.e. 00 33 66 99 CC or FF).
|
||||
|
||||
{p 4 4 2}Those wanting to include the CSS classes used by {cmd:log2html} should
|
||||
make an HTML file with the CSS option, and then look at the resulting
|
||||
page in a text editor. It will give more insight than any explanation here
|
||||
could give.
|
||||
|
||||
|
||||
{title:Options}
|
||||
|
||||
{p 4 8 2}{cmd:replace} specifies that if the HTML file exists, it is to be
|
||||
replaced.
|
||||
|
||||
{p 4 8 2}{cmd:erase} specifies that the SMCL log file is to be erased (deleted)
|
||||
after processing.
|
||||
|
||||
{p 4 8 2}{cmd:title()} specifies a string to be placed in the <TITLE> of the
|
||||
HTML page, and on the first line of the body of the page, using a <H2>
|
||||
heading.
|
||||
|
||||
{p 4 8 2}{cmd:linesize()} specifies a maximum line size for the result,
|
||||
i.e. the width in characters of rendered HTML lines. The argument
|
||||
must be between 40 and 255 inclusive. Default is the current linesize.
|
||||
|
||||
{p 4 4 2}The remaining options pertain to setting how the HTML page will appear
|
||||
when rendered in a browser.
|
||||
|
||||
{p 4 8 2}{cmd:percentsize()} specifies the scaling of the font to be used on
|
||||
the resulting HTML page as a percentage of the default. (The
|
||||
actual size is not specified, since it is typically specified by
|
||||
the person using the browser, not the person sharing the
|
||||
information.) This affects all text on the page.
|
||||
|
||||
{p 4 8 2}{cmd:bold} specifies that input lines (those resulting from
|
||||
user input), results from Stata, and error numbers be displayed as
|
||||
bold text.
|
||||
|
||||
{p 4 8 2}{cmd:scheme()} is the simplest way to change the colors of the
|
||||
resulting web page. The allowable schemes are
|
||||
|
||||
{p 8 10 12}{cmd:black}, {cmd:white}, or {cmd:blue}, which correspond closely
|
||||
to the colors of Stata's color schemes for the results window.
|
||||
|
||||
{p 8 10 12}{cmd:yellow}, which makes an easy-on-the-eyes page with
|
||||
a faint yellow background.
|
||||
|
||||
{p 4 8 2}{cmd:input()}, {cmd:result()}, {cmd:text()}, and {cmd:error()} can be
|
||||
used independently to set the foreground color of the text which corresponds to
|
||||
user input, Stata results, plain text output, and error numbers.
|
||||
|
||||
{p 4 8 2}{cmd:bg()} specifies the color of the background of the
|
||||
page. For convenience, this can be given as "grey" or "gray".
|
||||
|
||||
{p 4 8 2}{cmd:css()} specifies the cascading style sheet for the web
|
||||
page. This is an advanced option for people who use CSS for
|
||||
standardizing the appearance of their web sites. If you do not know
|
||||
what CSS means, there is no need to worry: if this option is
|
||||
omitted, {cmd:log2html} will put the proper information into the
|
||||
HTML file it creates.
|
||||
|
||||
|
||||
{title:Examples}
|
||||
|
||||
{p 4 8 2}{inp:. log using autostudy, replace}{p_end}
|
||||
{p 4 8 2}{inp:. use auto}{p_end}
|
||||
{p 4 8 2}{inp:. desc}{p_end}
|
||||
{p 4 8 2}{inp:. summ}{p_end}
|
||||
{p 4 8 2}{inp:. regress price mpg rep78}{p_end}
|
||||
{p 4 8 2}{inp:. log close}
|
||||
|
||||
{p 4 8 2}{inp:. log2html autostudy, replace}
|
||||
|
||||
{p 4 8 2}{inp:. log2html autostudy, replace ti(Automobile study)}
|
||||
|
||||
{p 4 8 2}{inp:. log2html autostudy, replace ti(Automobile study) scheme(black)}
|
||||
|
||||
{p 4 8 2}{inp:. log2html autostudy, replace in(ff3300) res(003333) bg(grey)}
|
||||
|
||||
{p 4 8 2}{inp:. log2html autostudy, replace ti(Automobile study) css("./mystyles.css")}
|
||||
|
||||
|
||||
{title:References}
|
||||
|
||||
{p 4 4 2}Priester, Gary W. 2000. All you need to know about web safe colors.{break}
|
||||
{browse "http://www.webdevelopersjournal.com/articles/websafe1/websafe_colors.html"}{p_end}
|
||||
|
||||
{p 4 4 2}Richmond, Alan. Introduction to style sheets.{break}
|
||||
{browse "http://www.wdvl.com/Authoring/Style/Sheets/Tutorial.html"}{p_end}
|
||||
|
||||
|
||||
{title:Acknowledgements}
|
||||
|
||||
{p 4 4 2}Ken Higbee helped with the documentation
|
||||
of {cmd:log html} and made suggestions for improvement of this routine.
|
||||
Renzo Comolli drew our attention to problems arising with long lines
|
||||
and quoted filenames. Friedrich Huebler also raised the issue of
|
||||
line size and Alan Riley and Joseph Coveney showed how to tackle it.
|
||||
|
||||
|
||||
{title:Authors}
|
||||
|
||||
{p 4 4 2}Christopher F Baum, Boston College, USA{break}
|
||||
baum@bc.edu{p_end}
|
||||
|
||||
{p 4 4 2}Nicholas J. Cox, Durham University, UK{break}
|
||||
n.j.cox@durham.ac.uk{p_end}
|
||||
|
||||
{p 4 4 2}Bill Rising, Bellarmine University, USA{break}
|
||||
wrising@bellarmine.edu{p_end}
|
||||
|
||||
|
||||
{title:Also see}
|
||||
|
||||
{p 4 13 2}Manual: {hi:[R] log}, {hi:[P] smcl}
|
||||
|
||||
{p 4 13 2}On-line: help for {help log}, {help smcl}
|
||||
|
61
Modules/ado/plus/l/log2html7.ado
Normal file
61
Modules/ado/plus/l/log2html7.ado
Normal file
@ -0,0 +1,61 @@
|
||||
*! log2html 1.1.1 cfb/njc 17Dec2001
|
||||
program define log2html7, rclass
|
||||
version 7.0
|
||||
syntax anything(name=smclfile id="The name of a .smcl logfile is") /*
|
||||
*/ [, replace TItle(string asis) INput(string) Result(string) BG(string)]
|
||||
|
||||
tempname hi ho
|
||||
tempfile htmlfile
|
||||
local smclfile : subinstr local smclfile ".smcl" ""
|
||||
local smclfile : subinstr local smclfile ".SMCL" ""
|
||||
local outfile `"`smclfile'.html"'
|
||||
qui log html `"`smclfile'"' `"`htmlfile'"', `replace' yebf whbf
|
||||
|
||||
local cinput = cond("`input'" == "", "CC6600", "`input'")
|
||||
local cresult = cond("`result'" == "", "000099", "`result'")
|
||||
|
||||
local cbg "ffffff"
|
||||
if "`bg'" ~= "" {
|
||||
if "`bg'" == "gray" | "`bg'" == "grey" { local bg "cccccc" }
|
||||
local cbg `bg'
|
||||
}
|
||||
|
||||
file open `hi' using `"`htmlfile'"', r
|
||||
file open `ho' using `"`outfile'"', w `replace'
|
||||
file write `ho' _n
|
||||
file write `ho' "<html>" _n "<head>" _n
|
||||
if `"`title'"' ~= "" {
|
||||
file write `ho' `"<title>`title'</title>"' _n
|
||||
file write `ho' `"<h2>`title'</h2>"' _n
|
||||
}
|
||||
file write `ho' "</head>" _n
|
||||
file write `ho' "<body bgcolor=`cbg'>" _n
|
||||
file read `hi' line
|
||||
|
||||
local cprev = 0
|
||||
|
||||
while r(eof)==0 {
|
||||
* command lines
|
||||
local line: /*
|
||||
*/ subinstr local line "<b>. " "<font color=`cinput'>. ", count(local c)
|
||||
|
||||
* catch continuation lines
|
||||
if substr(`"`line'"',1,7) == "<b>>" & `cprev' {
|
||||
local line : /*
|
||||
*/ subinstr local line "<b>" "<font color=`cinput'>", count(local c)
|
||||
}
|
||||
else {
|
||||
local line: /*
|
||||
*/ subinstr local line "<b>" "<font color=`cresult'>", all
|
||||
}
|
||||
|
||||
local line: subinstr local line "</b>" "</font>", all
|
||||
file write `ho' `"`line'"' _n
|
||||
local cprev = `c'
|
||||
file read `hi' line
|
||||
}
|
||||
file write `ho' "</body>" _n "</html>" _n
|
||||
file close `ho'
|
||||
di _n `"HTML log file `outfile' created"'
|
||||
end
|
||||
|
137
Modules/ado/plus/l/log2html7.hlp
Normal file
137
Modules/ado/plus/l/log2html7.hlp
Normal file
@ -0,0 +1,137 @@
|
||||
{smcl}
|
||||
{* 12 Dec 2001/25 March 2003}{...}
|
||||
{hline}
|
||||
help for {hi:log2html7}{right:SSC distribution 25 March 2003}
|
||||
{hline}
|
||||
|
||||
{title:Translate a SMCL log file into HTML}
|
||||
|
||||
{p 8 12}{cmd:log2html7}
|
||||
{it:smclfile}
|
||||
[{cmd:,}
|
||||
{cmd:replace}
|
||||
{cmdab:ti:tle}{cmd:(}{it:string}{cmd:)}
|
||||
{cmdab:in:put}{cmd:(}{it:string}{cmd:)}
|
||||
{cmdab:r:esult}{cmd:(}{it:string}{cmd:)}
|
||||
{cmd:bg(}{it:string}{cmd:)}
|
||||
]
|
||||
|
||||
|
||||
{title:Description}
|
||||
|
||||
{p}
|
||||
{cmd:log2html7} is for use after {cmd:log}; see {help log}. If
|
||||
you are using Stata 8 or later, use {cmd:log2html} instead.
|
||||
|
||||
{p} {cmd:log2html7} makes use of an undocumented command in Stata version 7,
|
||||
{cmd:log html}, which generates HTML log files from SMCL log files. SMCL, the
|
||||
Stata Markup and Control Language {help smcl}, is the default log file format
|
||||
introduced with version 7, and contains markup (similar to HTML) around
|
||||
elements of the log file. To use {cmd:log2html7}, you must first generate the
|
||||
default SMCL log file, not a text log file, with the file extension
|
||||
{cmd:.smcl}. Thus if you have {cmd:set logtype text} to prevent the generation
|
||||
of SMCL log files, you must either turn it off or explicitly state that a SMCL
|
||||
log file is to be produced, as by {cmd: log using my.smcl}.
|
||||
|
||||
{p} {cmd:log2html7} requires only the base name of the logfile: e.g. {cmd:my},
|
||||
if the logfile is named {cmd:my.smcl}. The name of the HTML file produced will
|
||||
be this base name with {cmd:.html} appended, e.g. {cmd:my.html}.
|
||||
|
||||
{p} {cmd:log2html7} requires that at least the 6 December 2001 update to Stata
|
||||
version 7 be installed. If a message "Invalid syntax" is encountered, please
|
||||
ensure that {cmd:query born} returns a date no earlier than 06 Dec 2001.
|
||||
|
||||
|
||||
{title:Limitation}
|
||||
|
||||
{p} {cmd:log2html7} cannot reliably echo {it:names} of local or global macros
|
||||
given on command lines in the log. This is because before being passed
|
||||
to the Stata command {cmd:file}, which does most of the hard work within
|
||||
{cmd:log2html7}, they are caught by Stata's parser and substituted with
|
||||
their current {it:contents}, if any. The usual result is to replace macro names
|
||||
with empty strings, although on occasion you may be fortunate enough to have
|
||||
the correct contents of a macro substituted, or unfortunate enough to
|
||||
have something quite different substituted, if the contents of a macro have
|
||||
changed since the log was created. This behavior is outside the
|
||||
control of the program authors, who know of no work-around in Stata 7.
|
||||
The limitation does not apply to {cmd:log2html} used in conjunction
|
||||
with Stata 8 or higher.
|
||||
|
||||
|
||||
{title:Options}
|
||||
|
||||
{p 0 4}
|
||||
{cmd:replace} specifies that if the HTML file exists, it is to be replaced.
|
||||
|
||||
{p 0 4}
|
||||
{cmd:title()} specifies a string to be placed in the <TITLE> of the HTML page,
|
||||
and on the first line of the body of the page, using a <H2> heading.
|
||||
|
||||
{p}
|
||||
The remaining options pertain to color choices. By default,
|
||||
{cmd:loghtml} produces a complete HTML page (i.e. with <HTML> and <BODY> tags)
|
||||
with a white background. Input lines (those resulting from user input) are
|
||||
rendered in RGB color "CC6600" (a shade of brown) and highlighted
|
||||
result-window lines are rendered in RGB color "000099" (a shade of blue).
|
||||
The options permit other choices for these three colors. For best results,
|
||||
one of the 216 "web safe" colors that display properly in web browsers on
|
||||
all computers in 256-color mode should be used. Also note that some
|
||||
combinations of colors are not workable; e.g. a black ("000000") background
|
||||
will cause all normally-rendered text to disappear.
|
||||
|
||||
{p 0 4}
|
||||
{cmd:input()} allows the specification of a different color for the user input
|
||||
lines, in standard RGB notation (three duples of two bytes, each 00-FF).
|
||||
|
||||
{p 0 4}
|
||||
{cmd:result()} allows the specification of a different color for the
|
||||
highlighted result lines, in standard RGB notation.
|
||||
|
||||
{p 0 4}
|
||||
{cmd:bg()} allows the specification of a different color for the background, in
|
||||
standard RGB notation. For convenience, the argument may be given as "gray"
|
||||
or "grey", approximating most browsers' default behavior.
|
||||
|
||||
|
||||
{title:Examples}
|
||||
|
||||
{p 4 8}{inp:. log using autostudy, replace}{p_end}
|
||||
{p 4 8}{inp:. use auto}{p_end}
|
||||
{p 4 8}{inp:. desc}{p_end}
|
||||
{p 4 8}{inp:. summ}{p_end}
|
||||
{p 4 8}{inp:. regress price mpg rep78}{p_end}
|
||||
{p 4 8}{inp:. log close}
|
||||
|
||||
{p 4 8}{inp:. log2html7 autostudy, replace}
|
||||
|
||||
{p 4 8}{inp:. log2html7 autostudy, replace ti("Automobile study")}
|
||||
|
||||
{p 4 8}{inp:. log2html7 autostudy, replace in(ff3300) res(003333) bg(grey)}
|
||||
|
||||
|
||||
{title:Reference}
|
||||
|
||||
Priester, Gary W. 2000. All you need to know about web safe colors.
|
||||
{browse "http://www.webdevelopersjournal.com/articles/websafe1/websafe_colors.html"}
|
||||
|
||||
|
||||
{title:Acknowledgements}
|
||||
|
||||
We acknowledge Ken Higbee's assistance with the documentation of
|
||||
{cmd:log html} and suggestions for improvement of this routine.
|
||||
|
||||
|
||||
{title:Authors}
|
||||
|
||||
Christopher F Baum, Boston College, USA
|
||||
baum@bc.edu
|
||||
|
||||
Nicholas J. Cox, University of Durham, UK
|
||||
n.j.cox@durham.ac.uk
|
||||
|
||||
|
||||
{title:Also see}
|
||||
|
||||
Manual: {hi:[R] log}, {hi:[P] smcl}
|
||||
On-line: help for {help log}, {help smcl}
|
||||
|
2672
Modules/ado/plus/l/logout.ado
Normal file
2672
Modules/ado/plus/l/logout.ado
Normal file
File diff suppressed because it is too large
Load Diff
193
Modules/ado/plus/l/logout.hlp
Normal file
193
Modules/ado/plus/l/logout.hlp
Normal file
@ -0,0 +1,193 @@
|
||||
{smcl}
|
||||
{* 05ov2009}{...}
|
||||
{cmd:help logout}
|
||||
|
||||
{hline}
|
||||
|
||||
{title:Title}
|
||||
|
||||
{p2colset 5 15 22 2}{...}
|
||||
{p2col :{hi: logout} {hline 2}}Converts log or ASCII files into various output formats{p_end}
|
||||
|
||||
{marker s_Syntax}
|
||||
{title:Syntax}
|
||||
|
||||
{p 4 10 6}
|
||||
{cmdab:logout}, [{it:options} : {it:command}]
|
||||
|
||||
{marker s_Description}
|
||||
{title:Description}
|
||||
|
||||
{p 4 4 6}
|
||||
{cmd:logout} provides a fast and easy way to convert log or ASCII files into various output
|
||||
formats compatible with Word, Excel, LaTex, or Stata datafile. Can be used as a prefix or by itself
|
||||
after a log file has been created.
|
||||
|
||||
{p 4 4 6}
|
||||
More specifically, {cmd:logout} will import plain-text files into tab-delimited format,
|
||||
which is then converted into the output format of choice. The default method is tab/space-delimited,
|
||||
along with a list of usual suspects. Alternatively, infix method can be used when the column position is meaningful.
|
||||
|
||||
{p 4 4 6}
|
||||
Can also be used to chew through dirty files such as html, etc. Will also chew through any ASCII log files,
|
||||
including those produced SAS, SPSS, etc. In Stata, you can use {cmd:{help caplog}} to create log files on
|
||||
the fly.
|
||||
|
||||
{p 4 4 6}
|
||||
{cmd:table} and {cmd:tabstat} are automatically handled by {opt fix} method.
|
||||
|
||||
|
||||
{marker s_Options}
|
||||
{title:Command}
|
||||
|
||||
{p 4 12 6}Any command accepted, i.e. { help estimation commands}, tabulation, summary, descrition, etc.
|
||||
|
||||
{marker s_Options}
|
||||
{title:Options}
|
||||
|
||||
{dlgtab:Main}
|
||||
|
||||
{p 4 12 6}{opt clear} Replace the current data in memory, then manipulate the file as a Stata data. {p_end}
|
||||
|
||||
{p 4 12 6}{opt save( )} The name of output file. logout.txt is assigned if {opt clear} or temporary file is not used. {p_end}
|
||||
|
||||
{p 4 12 6}{opt use( )} The name of input file to be converted. {p_end}
|
||||
|
||||
{p 4 12 6}{opt raw} Raw file is diplayed in the first column (up to 244 character limit). {p_end}
|
||||
|
||||
|
||||
{p 4 12 6}{opt fix} Use automatic fixed method (i.e. infix) to read the file. {p_end}
|
||||
|
||||
{p 4 12 6}{opt fix(#)} Adjust the sensitivity of {opt fix} method. Default is 5. Try 1 for narrower
|
||||
parsings.{p_end}
|
||||
|
||||
{p 4 12 6}{opt fixcut(# # ...)} Use manual fixed method (i.e. infix) to read the file. Something like fixcut(3 5 10 15). Drop a number
|
||||
if you want to merge columns there. A suggestion is displayed whenever fixed method is run{p_end}
|
||||
|
||||
|
||||
{p 4 12 6}{opt auto( )} The number of automatically formatted decimals to be reported. Default is 3. {p_end}
|
||||
|
||||
{p 4 12 6}{opt noauto} Turns off the automatic formatting of decimals.{p_end}
|
||||
|
||||
{p 4 12 6}{opt dec( )} Fixed number of decimals. Turns off automatic formating.{p_end}
|
||||
|
||||
{p 4 12 6}{opt word} Convert into Word compatible file. {p_end}
|
||||
|
||||
{p 4 12 6}{opt excel} Convert into Excel compatible file. {p_end}
|
||||
|
||||
{p 4 12 6}{opt tex} Convert into Latex or tex compatible file. {p_end}
|
||||
|
||||
{p 4 12 6}{opt dta} Convert into .dta file for Stata. {p_end}
|
||||
|
||||
|
||||
{p 4 12 6}{opt nowipe} Do not apply minimal cleaning, which are: {p_end}
|
||||
|
||||
{p 8 12 6} .drop if t1=="-----" | t1=="opened" | t1=="log" | t1=="." | t1=="closed" {p_end}
|
||||
|
||||
|
||||
{marker s_0}
|
||||
{title:Examples}
|
||||
|
||||
{p 4 10 6}{cmd:* summary}{p_end}
|
||||
{p 4 10 6}{stata sysuse auto, clear}{p_end}
|
||||
{p 4 10 6}{stata `"logout, save(myfile) excel replace: sum"'}{p_end}
|
||||
|
||||
|
||||
{p 4 10 6}{cmd:* summary, MANUALLY clean it}{p_end}
|
||||
{p 4 10 6}{stata sysuse auto, clear}{p_end}
|
||||
{p 4 10 6}{stata `"logout, clear: sum"'}{p_end}
|
||||
{p 4 10 6}{stata drop t2 t5 t6}{p_end}
|
||||
{p 4 10 6}{stata logout, save(myfile) excel replace}{p_end}
|
||||
|
||||
|
||||
{p 4 10 6}{cmd:* summary, detail}{p_end}
|
||||
{p 4 10 6}{stata sysuse auto, clear}{p_end}
|
||||
{p 4 10 6}{stata `"logout, save(mystuff) excel word replace: sum, detail"'}{p_end}
|
||||
|
||||
|
||||
{p 4 10 6}{cmd:* one-way tabulation with value labels}{p_end}
|
||||
{p 4 10 6}{stata sysuse auto, clear}{p_end}
|
||||
{p 4 10 6}{stata `"logout, clear excel dta tex save(myfile) replace: tab foreign rep78"'}{p_end}
|
||||
|
||||
|
||||
{p 4 10 6}{cmd:* one-way tabulation}{p_end}
|
||||
{p 4 10 6}{stata sysuse auto, clear}{p_end}
|
||||
{p 4 10 6}{stata `"caplog using mystuff.txt, replace: tabulate price [aweight=turn], summarize(headroom)"'}{p_end}
|
||||
{p 4 10 6}{stata logout, use(mystuff.txt) save(mytable) clear excel tex dta replace}{p_end}
|
||||
|
||||
|
||||
{p 4 10 6}{cmd:* two-way tabulation}{p_end}
|
||||
{p 4 10 6}{stata sysuse auto, clear}{p_end}
|
||||
{p 4 10 6}{stata `"logout, clear: tab mpg foreign"'}{p_end}
|
||||
{p 4 10 6}{stata logout, save(mytable) clear excel tex dta replace}{p_end}
|
||||
|
||||
|
||||
{p 4 10 6}{cmd:* table, combined it with -fix- method}{p_end}
|
||||
{p 4 10 6}{stata sysuse auto, clear}{p_end}
|
||||
{p 4 10 6}{stata `"logout, save(mystuff) excel fix replace: table trunk rep78, c(n mpg mean mpg sd mpg median mpg) stubwidth(25)"'}{p_end}
|
||||
|
||||
|
||||
{p 4 10 6}{cmd:* table, MANUALLY clean it after using -fix- or -fix(1)-}{p_end}
|
||||
{p 4 10 6}{stata sysuse auto, clear}{p_end}
|
||||
{p 4 10 6}{stata `"caplog using mystuff.txt, replace: table trunk rep78 , c(n mpg mean mpg sd mpg median mpg)"'}{p_end}
|
||||
{p 4 10 6}{stata logout, use(mystuff.txt) fix(1) replace clear}{p_end}
|
||||
{p 4 10 6}{stata drop in 1/2}{p_end}
|
||||
{p 4 10 6}{stata logout, save(mystuff.txt) excel replace clear}{p_end}
|
||||
|
||||
|
||||
{p 4 10 6}{cmd:* regress}{p_end}
|
||||
{p 4 10 6}{stata sysuse auto, clear}{p_end}
|
||||
{p 4 10 6}{stata `"logout, save(myfile) excel dec(3) replace: reg price mpg rep78 headroom"'}{p_end}
|
||||
|
||||
|
||||
{p 4 10 6}{cmd:* tabstat}{p_end}
|
||||
{p 4 10 6}{stata sysuse auto, clear}{p_end}
|
||||
{p 4 10 6}{stata `"logout, save(mytable) excel replace: tabstat price mpg rep78, stats( max p1 mean)"'}{p_end}
|
||||
|
||||
|
||||
{p 4 10 6}{cmd:* The following three are more or less equivalent:}{p_end}
|
||||
{p 4 10 6}{stata webuse dose, clear}{p_end}
|
||||
{p 4 10 6}{stata `"caplog using mylog.txt, replace: tab dose function, col"'}{p_end}
|
||||
{p 4 10 6}{stata chewfile using mylog.txt, begin(10) end(.) save(chewed.txt) replace}{p_end}
|
||||
{p 4 10 6}{stata `"logout, use(chewed.txt) clear fix"'}{p_end}
|
||||
{p 4 10 6}{stata `"logout, save(C:\mytable) tex excel replace"'}{p_end}
|
||||
|
||||
{p 4 10 6}{stata `"logout, save(C:\mytable) tex excel replace range(10/.) fix: tab dose function, col"'}{p_end}
|
||||
|
||||
{p 4 10 6}{stata `"logout, save(C:\mytable) tex excel replace range(10/.) fixcut(11 16 27 38 45 50 67): tab dose function, col"'}{p_end}
|
||||
|
||||
{p 4 10 6}{cmd:** Merging two columns by skipping a fixcut number:}{p_end}
|
||||
{p 4 10 6}{stata `"logout, save(C:\mytable) tex excel replace range(10/.) fixcut(11 27 38 45 50 67): tab dose function, col"'}{p_end}
|
||||
|
||||
|
||||
{title:Hints}
|
||||
|
||||
{p 4 10 6}The default is space/tab-delimited.{p_end}
|
||||
{p 4 10 6}For semi-ordered file, try using {opt fix} and values less than 5 for {opt fix( )}.{p_end}
|
||||
|
||||
|
||||
{title:Remarks}
|
||||
|
||||
{p 4 10 6}"Detailed" suggestions should be sent to the email address below.{p_end}
|
||||
{p 4 10 6}{opt fix} erases rows with many dashes as a horizontal line{p_end}
|
||||
{p 4 10 6}May not handle an exceptionally large log file.{p_end}
|
||||
{p 4 10 6}Small Stata may have a problem with the column limits.{p_end}
|
||||
{p 4 10 6}ASCII character "_" is used to handle space delimited value labels.{p_end}
|
||||
{p 4 10 6}version 7: do not include colon characters (:) in the file path. Use {helpb cd} instead.{p_end}
|
||||
{p 4 10 6}version 7: range( ) option not available.{p_end}
|
||||
|
||||
|
||||
{title:Acknowledgements}
|
||||
|
||||
{p 4 10 6}The codes for {opt word} and {opt tex} are traced back to John Gallup's
|
||||
{cmd:outreg} through {cmd:outreg2}.{p_end}
|
||||
{p 4 10 6}{opt excel} is implemented as a facsimile of {cmd:xmlsave}.{p_end}
|
||||
{p 4 10 6}Value labels are handled as proposed by Karl Keesman at sales@survey-design.com.au{p_end}
|
||||
|
||||
|
||||
{title:Author}
|
||||
|
||||
{p 4 10 6}Roy Wada{p_end}
|
||||
{p 4 10 6}roywada@hotmail.com{p_end}
|
||||
|
||||
|
Reference in New Issue
Block a user