home *** CD-ROM | disk | FTP | other *** search
-
- BEGIN {
- serr = "/dev/tty"; # standard error
- bs = "\\"; # used anytime I want a backslash
- mc = "multicolumn"; # short form
- bsmc = bs mc; # short form
-
- fnum = 4;
- if (putfree==1) fnum++; if (putt==1) fnum++;
- # how many fields/line is the generated table going to have?
-
- # Header:
- print bs "documentstyle[11pt]{article}";
- print bs "begin{document}"; print "";
- print bs "begin{table}[h]";
- print bs "centering";
-
- # Need to generate argument for \begin{tabular}
- if (putfree==1) {
- if (putt==1) llstring = "llcrrr";
- else llstring = "llcrr";
- }
- else {
- if (putt==1) llstring = "llrrr";
- else llstring = "llrr";
- }
- print bs "begin{tabular}{|" llstring "|} " bs "hline";
-
- # Headings at top of table:
- print bsmc "{" fnum "} {|l|} {} " bs bs;
- print " " bsmc "{1} {|l} {} & {Parameter}";
- if (putfree==1) print "& " bsmc "{1} {c} {Free?}";
- print "& " bsmc "{1} {c} {Estimate}";
- if (putt==0) # no t-stat
- print "& " bsmc "{1} {c|} {Standard Error}" bs bs;
- else {
- print "& " bsmc "{1} {c} {Standard Error}";
- print "& " bsmc "{1} {c|} {t-statistic} " bs bs;
- }
-
- # horizantal line and a blank line:
- print bsmc "{" fnum "}{|l|} {} " bs bs " " bs "hline";
- print bsmc "{" fnum "}{|l|} {} " bs bs;
- }
-
- # action on all lines:
- {taken = 0} # this line has not yet been parsed.
-
- # Look for captions
- ($1 ~ /[Cc][Aa]/) {
- # collect together text of caption:
- s = ""; for (i=2; i<=NF; i++) s = s $i " ";
- # file it away into variable "captionstring"
- captionstring = s;
- # it's used in END
- taken = 1;
- # say I have parsed this line.
- }
-
- # blank lines:
- ($1 ~ /[bB][lL]/) {
- if (NF != 1) {
- print "Error on line " NR ": only 1 field allowed." > serr;
- goch=1; exit 1;
- }
- else
- print bsmc "{" fnum "}{|l|} {} " bs bs;
- taken = 1;
- }
-
- # parameter estimates
- ($1 ~ /[eE][sS]/) {
- label = $2;
-
- # parse "free":
- free=-1; # error code is -1
- if (($3 ~ /[yY][eE][sS]/) || ($3 ~ /^[tT]/)) free=1;
- if (($3 ~ /[nN][oO]/) || ($3 ~ /^[fF]/)) free = 0;
- if (free == -1) {
- print "Error in FREE parameter on line " NR > serr;
- goch=1; exit 1;
- }
-
- # Check number of fields on the line is ok.
- expectfields = ((free == 0) ? 4 : 5);
- if (NF != expectfields) {
- print "Expect " expectfields " fields on line " NR > serr;
- goch = 1; exit 1
- }
-
- # Grab estimate, serror, compute t if needed.
- theta = $4;
- se=""; if (free==1) se=$5;
- t=""; if ((free==1) && (putt==1)) t = (1.0*theta)/(1.0*se);
-
- # Start creating the line to be emitted:
- s = "{} & {" label "}";
- if (putfree==1) s = s " & {" ((free==1) ? "Yes":"No") "}";
- s = s " & {" theta "} & {" se "}";
-
- if (putt==1) s = s " & {" t "} " bs bs;
- else s = s bs bs;
-
- print s;
-
- taken = 1;
- }
-
- # comment lines:
- ($1 ~ /[cC][oO]/) {
- s = ""; for (i=2; i<=NF; i++) s = s $i " ";
- print bsmc "{" fnum "}{|l|} {{" bs "sf " s "}}" bs bs;
- taken=1
- }
-
- # if taken is still zero for this line, it's garbage.
- (taken == 0) {
- print "Could not parse line " NR > serr;
- goch = 1; exit 1;
- }
-
- # Now close down things nicely and quit.
- END {
- if (goch == 1) {
- print "Fatal error... exiting" > serr
- exit 1;
- }
- print bs mc "{" fnum "}{|l|} {}" bs bs bs "hline";
- print bs "end{tabular}"
- print bs "caption{" captionstring "}";
- print bs "end{table}";
- print bs "end{document}";
- }
-
-