Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Re: Wild character in variable names?


From   "sdm1" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: Wild character in variable names?
Date   Mon, 12 Jan 2009 01:46:48 -0000

Thanks Fred and Martin.

Steve 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Martin Weiss
Sent: 11 January 2009 20:41
To: [email protected]
Subject: st: Re: Wild character in variable names?

Apart from Fred`s advice, you can also use a -forv- loop to accumulate the
condition:

**********
*create data
clear*
set obs 1000
forv i=1/10{
g t`i'=runiform()
}
g r=1
*get the condition
loc ts "t1<0.3"
forv i=2/10{
loc ts `ts' | t`i'<0.3
}
*do replacement
replace r=2 if `ts'
**********

HTH
Martin
_______________________
----- Original Message -----
From: "sdm1" <[email protected]>
To: <[email protected]>
Sent: Sunday, January 11, 2009 9:30 PM
Subject: st: Wild character in variable names?


>I have ten variables called diag1, diag2, ... diag10.
>
> I would like to do a replace such that:
>
> replace vara=1 if diag1=="A" | diag2=="A" | diag3=="A" ... .
>
> I would rather not have to write out all ten conditions.
> Is there a wild character, like *, I can use in the variable name so that
> this works:
>
> replace vara=1 if diag*=="A"
>
> Thanks.
>
> Steve
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
> 


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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