Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: programming with placeholders
From
"Parker, Sophie" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: programming with placeholders
Date
Thu, 27 Oct 2011 12:19:04 +0000
I'm new to programming in STATA. I would like to loop through the values of a string variable and use these as the name of the new var. In Fortran, this is the pound sign and variable name. The example is trying to sum all
the cargo shipments for each respective port over a time period, and creates a new var named sum#LoadPort - i.e., sumSingapore.
for i = 1/200
while LoadPort(i+1) = LoadPort(i)
gen sum#LoadPort = sum(FixtureCar)
end
end
I suppose this could also be done by generating variables from a two-way table but it'd be good to know if there's a way around this. Thanks for your consideration.
*
* 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/