The program is actually in this message. If you scroll down you see
inside the message by Michael a bunch of Stata code beginning with:
program define tabvals
and ending with:
end
Copy those lines and store them in a file called tabvals.ado in your
personal adopath. To find your personal adopaht type -adopath- in Stata
and look at the path labeled (PERSONAL). It is probably best to find
the original message by Michael so you won't have to edit out all the
"> >>". Also take care of line breaks.
Hope this helps,
Maarten
--- Michael McCulloch <[email protected]> wrote:
> Hello Statalist members,
> This -tabvals- program looks useful. I have searched the Stata site
> and the web without success. Is this a program that can be obtained
> for use?
> Thank you.
>
>
> >thank you for sharing your program, and thanks to all statalisters
> who
> >contributed to the discussion.
> >
> >Unfortunately, I have not managed to use *tabvals* successfully.
> >
> >By typing:
> >
> >sysuse auto, clear
> >replace rep78=. if rep78==1
> >tabvals rep78, values(1 2 3 4 5)
> >
> >I get:
> >
> >. tabvals rep78, values(1 2 3 4 5)
> >option if required
> >r(198);
> >
> >The syntax command in your code is likely to contain the information
> >on how to use the "if" option... but I must be missing somenthing:
> >*tabvals* refuses to cooperate with me... I would appreciate any
> help.
> >
> >- Giovanni
> >
> >
> >> -----Original Message-----
> >> From: [email protected]
> >> [mailto:[email protected]] On Behalf Of
> >> Michael Blasnik
> >> Sent: Friday, May 11, 2007 5:10 PM
> >> To: [email protected]
> >> Subject: Re: st: an ordinary two-way table
> >>
> >> I just recalled that I had written a program with the same
> >> goal a while back and it will do what you ask:
> >>
> >> program define tabvals
> >> version 8.0
> >> *! v 1.0 M Blasnik
> >> syntax varlist( min=1 max=2) [if] [in], values(numlist)
> >> [MISSing] * if "`missing'"!="" { local novarlist "novarlist"
> >> }
> >> marksample touse , `novarlist'
> >> loca l var: word 1 of `varlist'
> >> qui levels `var' if `touse', local(hasvals) `missing'
> >> local addvals: list values - hasvals
> >> local tempobs: word count `addvals'
> >> if `tempobs'>0 {
> >> preserve
> >> local origN=_N
> >> qui expand `tempobs'+1 in l
> >> tempvar real
> >> qui gen byte `real'=(_n<=`origN')
> >> qui replace `touse'=1 in -`tempobs'/l
> >> forvalues i=1/`tempobs' {
> >> local obsn=`origN'+`i'
> >> local val: word `i' of `addvals'
> >> qui replace `var'=`val' in `obsn'
> >> }
> >>
> >> noi tab `varlist' if `touse', subpop(`real') `missing' `options'
> >> restore
> >> }
> >> else {
> >> noi tab `varlist' if `touse' , `missing' `options'
> >> }
> >> end
> >>
> >> Hopefully there aren't any word wrap problems or you may need
> >> to fix this code up. It lets you specify a values numlist
> >> that applies to the first variable in the tabulate command.
> >> It allows you to specify a second variable but does not
> >> create new values for that one. Since it relies on Stata's
> >> tabulate command, it provides all of the options allowed with
> >> tabulate.
> >>
> >> Michael Blasnik
> >>
> >>
> >>
> >> ----- Original Message -----
> >> From: "Giovanni Vecchi" <[email protected]>
> >> To: <[email protected]>
> >> Sent: Friday, May 11, 2007 10:07 AM
> >> Subject: RE: st: an ordinary two-way table
> >>
> >>
> >> > Chris and Nick, thanks for your suggestions. As you both say,
> the
> >> > problem with tabcount is that it does not allow row and
> >> column totals.
> >> >
> >> > I'm always puzzled when I find Stata unable to offer easy
> answers
> >to
> >> > easy questions (as the one raised in my posting). Faced with
> the
> >> > failure to produce a simple two-way table, I ask myself: is it
> me
> >or
> >> > is it Stata? And my answers start looping ... "it's me",
> >> "it's Stata",
> >> > "it's me", "it's Stata",... time goes by,
> >> frustration/irritation start
> >> > off, etc...
> >> >
> >> > A quick reaction to Nick's suggestion. In my opinion, there is
> an
> >> > issue on the opportunity cost of pursuing a Mata-based
> strategy.
> >My
> >> > guess is that it is high for most Stata users.
> >> >
> >> > My point: ordinary two-way tables should be within the reach of
> >> > Mata-almost-illiterate users. Needless to say, I am an
> outstanding
> >> > member of this club.
> >> >
> >> > A bottom line: hope StataCorp is sympathetic to my argument...
> :)
> >> >
> >> > Best,
> >> >
> >> > - Giovanni
> >>
> >> *
> >> * For searches and help try:
> >> * http://www.stata.com/support/faqs/res/findit.html
> >> * http://www.stata.com/support/statalist/faq
> >> * http://www.ats.ucla.edu/stat/stata/
> >
> >*
> >* For searches and help try:
> >* http://www.stata.com/support/faqs/res/findit.html
> >* http://www.stata.com/support/statalist/faq
> >* http://www.ats.ucla.edu/stat/stata/
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands
visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434
+31 20 5986715
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
___________________________________________________________
Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/