Statalist The Stata Listserver

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

st: Re: tabulate with gen

From   Hebe.B.Quinton@Dartmouth.EDU (Hebe B. Quinton)
Subject   st: Re: tabulate with gen
Date   07 Aug 2006 17:31:30 EDT


Thought I would answer my own question.  While tab foo, gen(foo_) does create
consecutively numbered dummy variables, xi: will preserve the natural value of
the underlying variable.  This I found out while complaining at the water


xi: regress sex
creates _Icenter_## varibles
where ## is the value of the center variable, now coded as 0,1.
If you don't like the _Icenter_ there is another cute command:
renpfix _Ic c
which renames all those variables to center_##

So, as they say, "Never mind."


--- I wrote:
I use

 tab foo, gen(foo_)

all the time to create dummy variables based on the values of foo - I get
foo_1, foo_2, etc.

Does any one have a technique (I won't call it a trick) for having the
extension be the actual value of foo?  For example, I have health care center
numbers that are NOT continuously numbered from 1 to 100, so the dummy and the
root value quickly get out of synch:


tab center, gen(center_)

creates center_3 that corresponds to center==5, center_4 corresponds to
center==6, etc

Seems like a recipe for disaster when generating reports....!

I can generate a do file to rename them, but I though someone else might have
solved this problem.
--- end of quote ---

Hebe Quinton 
Dartmouth Hitchcock Medical Center
Clinical Research/Department of Medicine
506 Rubin
One Medical Center Drive
Lebanon, NH  03756

(603) 653-3536
Fax (603) 653-3554
*   For searches and help try:

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