Statalist The Stata Listserver

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

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

From   "Nick Cox" <>
To   <>
Subject   st: RE: tabulate - displaying value labels and numeric codes simultaneously
Date   Thu, 15 Mar 2007 18:39:02 -0000

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' 

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


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:

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