Two kinds of answer: 
1. As you -reshape- to wide a variable name like 
-foo- will become the stub of a set of 
variable names, so in many cases a wildcard like 
-foo*- will be sufficient to characterise 
the set. That wouldn't be precise enough if 
you also had e.g. -foot-. You might need 
e.g. -foo????-. 
 
Typically you can loop over such 
a set of variables using -foreach- without 
knowing how many of them exist. One way to 
count them would be 
unab foo : foo* 
local nvars : word count `foo' 
2. It may be that what you want to do 
is much more efficiently done within the long 
structure before the -reshape-, or without the 
-reshape-. 
Nick 
[email protected] 
Jason Rachlin
> 
> I am reshaping my data so each date becomes a column.  I will 
> not know how many
> dates are in my dataset and thus will not know how many 
> columns I have.  I'd like
> to loop across the columns performing an operation once for each date.
> 
> > program then loops over these dates performing a function.  
> I'd like to loop
> > until I hit the last date in my dataset which will change 
> each time I run the
> > program depending on the size of the dataset.  Can someone 
> please recommend an
> > efficient way to identify my last column so I can define NumDays?
> >
> > local NumDays = ?
> > local i = 1
> > while `i' <= NumDays {
> >     ...
> > }
> >
*
*   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/