Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: cut variables


From   adiallo5@worldbank.org
To   statalist@hsphsun2.harvard.edu
Subject   st: cut variables
Date   Thu, 10 Nov 2005 10:41:48 -0500

g x2 = substr(x,1,2)


                                                                                 
                                                                                 
                                                                                 
 -----Original Message-----                                                      
 From: owner-statalist@hsphsun2.harvard.edu                                      
 [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Patricia Vera         
 Rojas                                                                           
 Sent: 10 November 2005 15:24                                                    
 To: statalist@hsphsun2.harvard.edu                                              
 Subject: st: cut variables                                                      
                                                                                 
                                                                                 
 Hi,                                                                             
                                                                                 
 I have a string variable with different size:                                   
                                                                                 
 01 XXX YYY ZZZ                                                                  
 02 XXXX YYY ZZZZZZ                                                              
 .                                                                               
 .                                                                               
 .                                                                               
 .                                                                               
 .                                                                               
 30 X Z YYYYY                                                                    
                                                                                 
 I want to get only the first two digits (01 to 30)                              
 How can I do it?                                                                
                                                                                 
 Thanks,                                                                         
 Patricia                                                                        
                                                                                 
                                                                                 
 ------------------------------------------------------------------------------- 

*
*   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