Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: AW: Categorize variable


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: AW: Categorize variable
Date   Mon, 12 Apr 2010 17:45:57 +0200

<> 

BTW, my solution is a bit more complicated than initially imagined
(http://www.stata.com/statalist/archive/2002-08/msg00178.html):

*************
clear*
set seed 123456
set obs 1000
gen weight=rnormal(165,6)
su weight, mean
egen float mygroups = cut(weight), at(`=r(min)-0.01' 150(10)180 `r(max)')
icodes
la def mylab 0 "<150" 1 "150-160" 2 "160-170" 3 "170-180" 4 ">180"
la val mygroups mylab
table mygroups, contents(freq min weight max weight) mis
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Martin Weiss
Gesendet: Montag, 12. April 2010 17:31
An: statalist@hsphsun2.harvard.edu
Betreff: st: AW: Categorize variable


<> 


Look at -help egen, cut()-



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Saretta
Gesendet: Montag, 12. April 2010 17:29
An: statalist@hsphsun2.harvard.edu
Betreff: st: Categorize variable

I have a continuous variabile called weight. How can I categorize this 
variable into groups: <=150lb (150-160], (150-160], (170-180] and >180?
thank you
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index