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, **statalist.org** is already up and running.

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

From |
Steven Samuels <sjsamuels@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: Calculating average value using STATA program language |

Date |
Mon, 12 Sep 2011 00:48:11 -0400 |

Welcome to Statalist! Like most of us, I'm sure you just briefly scanned the FAQ when you joined, so it was easy to miss the contents of the last entry: that the proper way to write the name of our program is "Stata", not "STATA" The all-upper-case names of programs like SAS ("Statistical Analysis System") and SPSS ("Statistical Package for the Social Sciences") are acronyms: their letters stand for words in the original names. That's not true of Stata; hence it is spelled like a regular name, with only the first letter capitalized. Steve On Sep 12, 2011, at 12:10 AM, Suryadipta Roy wrote <<>> Hello everyone, I am a newbie in terms of writing STATA codes, and intend to get that corrected pretty soon. Meanwhile, I was wondering if any one could help me with the following. I have been trying use foreach/forvalues without any success for some time. Any help/suggestion/hint is greatly appreciated. importer exporter year isic imports sum_import avg_import AUS FRA 1979 311 8 24 12 AUS FRA 1980 311 16 24 12 AUS FRA 1979 313 0 0 0 AUS FRA 1980 313 0 0 0 AUS GAB 1979 369 0 0 0 AUS GBR 1976 311 10 30 10 AUS GBR 1977 311 20 30 10 AUS GBR 1978 311 0 30 10 AUT CAN 1977 312 10 10 10 AUT CAN 1978 390 20 20 20 FRA AUS 1976 311 5 10 5 FRA AUS 1977 311 5 10 5 FRA AUT 1980 369 4 4 4 In the hypothetical dataset above, I am trying to create the last two columns (sum_import, and avg_import) from the "imports" column. For the first column, the idea is to calculate the sum of imports e.g. from FRA to AUS for each industry category (isic). Thus for the isic category 311, the sum of imports in 1979 and 1980 is 8 + 16 = 24, and the average in the two years is 12. Similarly, there were no trade between AUS and GAB in 1979 for the industry category 369, and hence the sum and the average value of imports = 0. The actual dataset has over 200 countries covering data from 1976 - 1980 and I am trying to calculate the average of the imports between 1976- 1980 in each industry category. There are 28 such industry categories. I remain grateful for any help. Sincerely, Suryadipta. * * 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/ * * 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/

**Follow-Ups**:**Re: st: RE: Calculating average value using STATA program language***From:*Suryadipta Roy <sroy2138@gmail.com>

**References**:**st: Calculating average value using STATA program language***From:*Suryadipta Roy <sroy2138@gmail.com>

- Prev by Date:
**Re: st: spmap guidance: Two variables resulting in shaded and sized circles centered on lon/lat** - Next by Date:
**Re: st: spmap guidance: Two variables resulting in shaded and sized circles centered on lon/lat** - Previous by thread:
**st: RE: Calculating average value using STATA program language** - Next by thread:
**Re: st: RE: Calculating average value using STATA program language** - Index(es):