Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: command forvalues with multiple if expressions

From   Maarten buis <>
To   "" <>
Subject   Re: st: command forvalues with multiple if expressions
Date   Tue, 3 May 2011 09:15:15 +0100 (BST)

--- Martijn Stouthart
> I have a problem getting the forvalues command working the way I want.
> I have the following problem. I have the following variables:
> cftassets3ysd, industrycode and year. Where industrycode has a range
> from 1-100 and year a range of 1999 to 2009.
> Now I want the following. I want for each industrycode in each year
> the mean of cftassets3ysd belonging to that industrycode in that year.
> Preferably I want all values be generated in one column. I also have
> to note that some observations of  cftassets3ysd have missing values,
> so as a result I want those to be treated in the right way, thus as
> missing values.
> Unfortuneatly I cannot get the forvalues loop working.

This is not a -forvalues- problem. Just type:
bys industrycode year : egen industrysigma = mean(cftassets3ysd)

Hope this helps,
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index