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 at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: generating variable if condition met


From   Caliph Omar Moumin <sheikmoumin@yahoo.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: generating variable if condition met
Date   Thu, 5 Jul 2012 10:38:42 -0700 (PDT)

Thank you Phil


Kind Regards,
Moumin

Email:  sheikmoumin@yahoo.com 



----- Original Message -----
From: Phil Clayton <philclayton@internode.on.net>
To: statalist@hsphsun2.harvard.edu
Cc: 
Sent: Thursday, July 5, 2012 2:05 PM
Subject: Re: st: generating variable if condition met

I would use -destring- then -recode-, eg:

destring hproblem, replace
recode hproblem (1/50 53/103 ... 356/362=1) (nonmissing=2), gen(group)

See -help destring- and -help recode-. The above -destring- command will only work if you genuinely only have numbers in hproblem. There are various other options for recoding numeric variables documented in the user manuals.

Phil

On 05/07/2012, at 9:56 PM, Caliph Omar Moumin wrote:

> Dear All
> 
>  
> There is a string variable ‘hproblem’ containing diseases classification, which has codes from 1- 436.
> I want to generate a variable ‘type’ which is ‘hproblem’ classified into two; 1 for group1 and 0 for group2.
> The following codes of the variable ‘hproblem’ required to be included in group1
> 1-50, 53-103, 124-165, 167, 171, 175 -182, 188-200, 223-252, 257, 262-287, 313-336, 356-362
> AND ALL THE REST in group two.
> Is there a simple way to generate variable ‘type’?
> Kind Regards,
> Moumin
> 
> Email:  sheikmoumin@yahoo.com 
> 
> 
> *
> *  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?searchhttp://www.stata.com/support/statalist/faqhttp://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