Statalist The Stata Listserver


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

Re: st: Re: interested in tabvals


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   Re: st: Re: interested in tabvals
Date   Sun, 13 May 2007 12:38:04 -0400

I just posted the clarification for that exact portion of code yesterday -- didn't you see it on Statalist?
The correct lines there are numbered below (done include the number and it open parentheses)


*** ? ***
1) syntax varlist( min=1 max=2) [if] [in], values(numlist) [MISSing] *

2) if "`missing'"!="" {

3) local novarlist "novarlist"

4) }


I don't plan to put in semi colon delinmiters. I'd rather just post it to SSC once I write a help file.


----- Original Message ----- From: "John LeBlanc" <[email protected]>
To: "Michael Blasnik" <[email protected]>
Sent: Sunday, May 13, 2007 9:17 AM
Subject: Re: st: Re: interested in tabvals



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 {
 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

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: [email protected]
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
file.
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" <[email protected]>
To: <[email protected]>
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:
* 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/



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