Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Forvalues Problem


From   "Steichen, Thomas J." <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Forvalues Problem
Date   Fri, 24 Feb 2006 17:25:11 -0500

Raph,

Try:

foreach i of numlist 3 7 8 10/30 35 37 80/100 {
       gen byte d`i' = strmatch(diag,"*D`i'*")
}

Tom

Thomas J. Steichen
[email protected]
----------------------------------------------------------------------------
  Facts do not cease to exist because they are ignored. - Aldous Huxley
----------------------------------------------------------------------------



> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> Raphael Fraser
> Sent: Friday, February 24, 2006 5:19 PM
> To: [email protected]
> Subject: Re: st: RE: Forvalues Problem
> 
> 
> foreach i in 3 7 8 {
> 
>  worked fined but that was a simple example. I'd like to do 
> the following
> 
> foreach i in 3 7 8 10/30 35 37 80/100 {
>       gen byte d`i' = strmatch(diag,"*D`i'*")
> }
> unfortunately foreach does not have this capability. Nor does 
> forvalue. Any more suggestions?
> 
> On 2/24/06, [email protected] <[email protected]> wrote:
> > I'd use
> >
> > foreach i in 3 7 8 {
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Raphael 
> > Fraser
> > Sent: Friday, February 24, 2006 4:41 PM
> > To: [email protected]
> > Subject: st: Forvalues Problem
> >
> >
> > I am trying to perform a loop for the values 3, 7 and 8. I keep 
> > getting the invalid syntax error message. Can anyone offer 
> a solution?
> >
> > forvalues i = 3 7/ 8 {
> >         gen byte d`i' = strmatch(diag,"*D`i'*")
> > }
> >
> > Raphael
> >
> > *
> > *   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/
> >
> 
> *
> *   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/
> 

-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any
attachment(s), contains information that may be confidential,
protected by the attorney-client or other legal privileges, and/or
proprietary non-public information. If you are not an intended
recipient of this message or an authorized assistant to an intended
recipient, please notify the sender by replying to this message and
then delete it from your system. Use, dissemination, distribution,
or reproduction of this message and/or any of its attachments (if
any) by unintended recipients is not authorized and may be
unlawful.


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