Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: programming with placeholders

From   "Parker, Sophie" <>
To   "" <>
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)



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:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index