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

Re: st: creating a newvar with sequential values from a bunch of string variables


From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: creating a newvar with sequential values from a bunch of string variables
Date   Sat, 25 Jun 2005 13:12:50 -0500

At 01:35 PM 6/25/2005 -0400, Suzy wrote:
replace newvar=1 if var1 =="71600/71699" | var2=="71600/71699" | var3=="71600/71699" | var4=="71600/71699"
(0 changes made)

But no changes occurred, which is impossible.
I'm not sure if this would work but it seems like you need to rework your quote marks, e.g.

replace newvar=1 if var1 =="71600"/"71699" etc.

Even so, I'm not clear on how your 2 pieces of code are supposed to be equivalent, i.e. the first snippet sets newvar to 44 and the 2nd snippet sets it to 1.

Also I wonder if your life would be easier if you used the -destring- command to create numeric versions of these string variables; see the help for destring.

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal): http://www.nd.edu/~rwilliam
WWW (department): http://www.nd.edu/~soc

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