Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: generating variable if condition met


From   ananou foly <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: generating variable if condition met
Date   Thu, 5 Jul 2012 13:06:38 +0100 (BST)

Hi. Try to do this : 
 
 
gen type=0
forv i = 1(1)50 53(1)103 124(i)165 167 171 175(1)182 188(1)200 223(1)252 257 262(1)287 313(1)336 356(1)362{
replace type = 1 if hproblem == `i' 
} 

the first line allow u to gen the variable "type" assuming then that they are aull in group2 and then the rest allow u to extract those frome group1. 
 
Regards. Foly

________________________________
De : Caliph Omar Moumin <[email protected]>
À : "[email protected]" <[email protected]> 
Envoyé le : Jeudi 5 juillet 2012 11h56
Objet : st: generating variable if condition met

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:  [email protected] 


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index