From | Suzy <scott_788@wowway.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: RE: creating a newvar with sequential values from a bunchof string variables |
Date | Sun, 26 Jun 2005 12:57:24 -0400 |
It's not impossible at all. Stata takes literally
what you include between double quotes " ". Evidently you had no strings with values like "71600/71699".
However, it may be that what you want is accomplishable by something like
forval i = 1/4 { replace newvar = 1 if inrange(real(var`i'),71600,71699) }
but like Richard Williams I am not completely clear from your examples what exactly you do want.
Nick n.j.cox@durham.ac.uk
Suzy
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!!
* 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/
* * 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–2025 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |