Hello, everyone
I am using Stata SE 14 to try to convert Stata codebook to a LaTex table document using Daniel Becker's do-file "codebook.do" (http://www.jpberlin.de/d.becker/stata-latex.html). This do-file is working very nicely and will return a LaTex table containing the compact codebook. However, I would like to customize the codebook a bit by adding frequencies of each value of a variable instead of just the default information of the compact codebook (i.e., observations, unique values, missing, min, max, mean and variable label). The codes for calculating the compact codebook in the do-file are as follows:
My question is: let's say my Variable 1 has three possible values: 1 = father, 2 = mother, 3 = siblings, . = missing. I would like the codebook table also display the frequencies of each value for this Variable 1 (including ". = missing"). What and where do I need to make the modifications in the do-file? I am relatively new to Stata. Please do bear with me if this post appears to be elementary. Many thanks!
Sincerely,
Biru
I am using Stata SE 14 to try to convert Stata codebook to a LaTex table document using Daniel Becker's do-file "codebook.do" (http://www.jpberlin.de/d.becker/stata-latex.html). This do-file is working very nicely and will return a LaTex table containing the compact codebook. However, I would like to customize the codebook a bit by adding frequencies of each value of a variable instead of just the default information of the compact codebook (i.e., observations, unique values, missing, min, max, mean and variable label). The codes for calculating the compact codebook in the do-file are as follows:
Code:
foreach y of var *{; /* take care of LaTeX special in Variablenames */ local x = subinstr("`y'","_","\_",9); /* calculate entries of table */ unique `y'; local observ = r(N); local unique = r(sum); quietly tabmiss `y'; local missings = r(sum); local missingsperc = r(mean)*100; /* local missingsperc = round(r(missingsperc),0.1); */ local missingsperc = string(`missingsperc',"%9.0f"); quietly sum `y'; local mean= round(r(mean),0.1); local mean = string(`mean',"%9.1f"); local min = r(min); local min = string(`min',"%9.1f"); local max = round(r(max),0.1); local max = string(`max',"%9.1f"); local labelofvariable: variable label `y';
Sincerely,
Biru
Comment