Statalist


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

st: RE: foreach loop over a column


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: foreach loop over a column
Date   Wed, 14 Oct 2009 00:58:07 +0200

<>

Example:

**************
sysuse auto, clear
levelsof rep78
	foreach num in `r(levels)'{
	di `num'
}
**************


Note that the -by- prefix can replace these loops in many cases...

HTH
Martin


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Kushan Thakkar
Sent: Mittwoch, 14. Oktober 2009 00:53
To: [email protected]
Subject: st: foreach loop over a column

I have a column name permno in my dataset. It is a numerical column,
and I want to loop over it. This is what I did:

foreach num in permno {
       // do something
}

but this is not working.. what am i doing wrong?

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