Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: interested in tabvals

From   John LeBlanc <>
To   Michael Blasnik <>
Subject   Re: st: Re: interested in tabvals
Date   Sun, 13 May 2007 10:17:05 -0300

Michael, it is not clear for novice programmers like me to detect where 
word-wrapping is a problem. If you have time, perhaps you could change 
the delimiter to something like ';'. Alternatively, I"ve cleaned it up 
as best as I can figure out but I'm puzzled by the section I've marked 
with ***?***. Are the <CR> correct?

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'
local 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 {
  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'
else {
 noi tab `varlist' if `touse' , `missing' `options'

John LeBlanc

John C. LeBlanc, MD, MSc, FRCPC
Associate Professor
Pediatrics, Psychiatry, Community Health and Epidemiology
Dalhousie University

IWK Health Centre               Work phone: (902) 470-8930
5850 University Avenue          Work fax:   (902) 470-6913
Halifax, Nova Scotia            Email: John.LeBlanc@Dal.Ca
B3K 6R8 CANADA                  Pager:      (902) 470-8888

On Sat, 12 May 2007 12:58:46 -0400, Michael Blasnik wrote:
I just posted it on Statalist in this thread -- that's the only way to 
get it
now.  I have not made it available any other way since I thought
that -tabvalues- accomplished the same thing.  I guess there are some
differences, so I might post it to SSC if I get around to writing a help 
In the mean time, just use the Statalist archives to retrieve my message 
and fix
any word wrap problems  and save it to your local ado folder.
Michael Blasnik
----- Original Message -----
From: "Michael McCulloch" <>
To: <>
Sent: Saturday, May 12, 2007 12:15 PM
Subject: st: interested in tabvals
> 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.
*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index