Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Suryadipta Roy <sroy2138@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: RE: Calculating average value using STATA program language |
Date | Mon, 12 Sep 2011 00:53:47 -0400 |
Steve, Sorry about it! I have been in and out of the Statalist, but did not go through the FAQ carefully this time. I will certainly keep it in mind before my next post. Sincerely, Suryadipta. On Mon, Sep 12, 2011 at 12:48 AM, Steven Samuels <sjsamuels@gmail.com> wrote: > 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/ > * * 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/