Statalist The Stata Listserver


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

st: RE: tabulate with gen


From   <T.M.Carayol@lse.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: tabulate with gen
Date   Mon, 7 Aug 2006 16:36:42 +0100

Hi,

Here is something you could do :

levelsof foo, local(levels)
foreach l of local levels {
gen foo_`l' = (foo==`l')
}

I actually faced the same problem a few days ago, and that's what I came
up with.

Hope it helps !

Timothee

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Hebe B.
Quinton
Sent: 07 August 2006 16:31
To: statalist@hsphsun2.harvard.edu
Subject: st: tabulate with gen

Hello -

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:

center
1
2
5
6
7
8

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.

Thank you,

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

Pedestrians on the Sidewalk of Average Intelligence, hie thee to the
nearest
underpass. Itis raining baloney.
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index