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

st: RE: Dealing with string variables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Dealing with string variables
Date   Wed, 10 Nov 2004 15:46:26 -0000

drop if grain == "wheat" 

value labels for string variables: 
not allowed 

what you want is better done by 

gen Crop = "crop" if inlist(crop, "wheat", "barley") 
replace Crop = "root" if inlist(crop, "potato", "cassava", "yams", "beet") 
... 

Nick 
[email protected] 

TEWODAJ MOGUES
 
> For the longest time I have been trying to find ways around certain 
> commands that would involve string variables, but I can't 
> believe that 
> these commands really don't exist. Hence my question: For example, 
> if "grain" is a string variable, how do I do an operation 
> such as "drop 
> if grain==wheat"? Similarly, how do I create value labels for string 
> variables. For example, if I want the variable "grain" to have the 
> value label "crop" when it takes on the value "wheat" and "barley"? I 
> would be delighted if I didn't have to find laborious ways of data 
> manipulation where dealing directly with the string variables 
> would be much easier.

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index