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

st: creating a newvar with sequential values from a bunch of stringvariables


From   Suzy <[email protected]>
To   [email protected]
Subject   st: creating a newvar with sequential values from a bunch of stringvariables
Date   Sat, 25 Jun 2005 13:35:19 -0400

Dear members:

I created a new variable (newvar) that is supposed to be a collection of sequential values from different string variables. The values that are included in the new variable go from 71600 to 71699. I've been doing it manually for hours- replacing value after value. see example for value # 71623:

replace newvar=44 if var1 =="71623" | var2=="71623" | var33=="71623" | var4=="71623"
(10 real changes made)


I tried to do it this way - see example:

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 hoping there is a simple and quick syntax for what I'd like to do. Ideally if newvar =1 with all the values from 71600 t0 71699 located from the existing variables (1-4) included in newvar - then that would be less painful than what I've been doing.

Any simple solution?? explicit code is appreciated!!
Thanks,
Suzy


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