Statalist The Stata Listserver


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

Re: st: RE: tabulate - displaying value labels and numeric codes simultaneously


From   "Daniel Stegmueller" <[email protected]>
To   [email protected]
Subject   Re: st: RE: tabulate - displaying value labels and numeric codes simultaneously
Date   Thu, 15 Mar 2007 21:49:03 +0100

Nick,,

(1) your piece of code does the job just fine, thank you!

(2) you are certainly right, discussing the problems of Jeroen's code
without him being present is not the best idea... I sent him an email
about this discussion  this afternoon ...

Daniel




2007/3/15, Nick Cox <[email protected]>:
A rather convoluted thread started by this leaves me
with two thoughts.

1. The thread converged on taking a program by Jeroen
Weesie called -tabl- and discussing how to fix it.

At the risk of seeming pompous, I have to protest
at a small example here of some poor practices.

People with long Stata experience are taking someone
else's program, changing it, not changing the name,
and not documenting what it is that they changed, even
to the extent of not knowing how it differs.

You can do this in private if you want, but longstanding
advice is that _you should not do it in public_.
It is not heinous, but it is sloppy and potentially
confusing or irritating.

Here the advice is again: Statalist FAQ 6.4:

"However, StataCorp has nonexclusive rights to any program
published in the STB or SJ, while anything placed in the SSC
Archive is tacitly put in the public domain. In practice, you
can probably take anything published in either medium and
modify it as you will -- especially if you do that privately --
but publicly we recommend that unless you are the original
author, you should change the name of the program, take all
blame for any limitations your changes produce, and imply
that a suitably large portion of the credit for the program
belongs to the original authors."

-tabl- was published in STB-53 and a later version is
downloadable from Jeroen's website. I don't think programs
from other websites deserve a different standard of behaviour.

This revised program may of course get passed on and, who
knows, someone downstream is going to email Jeroen Weesie
and ask him some dopey question about something with his name
on for which he is not responsible. Jeroen is not, I believe,
a member of Statalist, so not able to answer questions about
-tabl- on Statalist, but his rights deserve a little more respect.

2. That said, what is the problem posed and does -tabl-
solve it? The wish is to see numbers and labels and not
change the data, but what -tabl- does is an analogue of
-tab1-, and it does not mirror the full range of options
of -tabulate <varname>-, nor does it allow two-way tables.

Much of the latter can be done more directly. Here you
need -labvalclone- from -labutil-:

*! NJC 1.0.0 15 March 2007
program tabnl
        version 8
        syntax varlist(min=1 max=2) [if] [in] [fweight aweight iweight] [, *]

        foreach v in `varlist' {
                local lblname : value label `v'
                if "`lblname'" != "" {
                        tempvar V
                        tempname temp
                        clonevar `V' = `v'
                        labvalclone `lblname' `temp'
                        numlabel `temp', add
                        label val `V' `temp'
                        local newlist `newlist' `V'
                }
                else local newlist `newlist' `v'
        }

        tab `newlist' `if' `in' [`weight' `exp'] , `options'
end

Analogues of this to match -tab1- and -tab2- would need only
changes on two lines, I believe.

Nick
[email protected]

Daniel Stegmueller

> I invoke the following sequence of commands quite regularly: - tab x-
> followed by -tab x, nolabel-  in orer to see value labels and their
> numeric counterparts.
>
> Is there a quick way(i.e. has anybody written an ado...) to display
> both simultaneously (without using -codebook- of course...)

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