Dear statalisters,
my data set contains 113 variables that belong to 62 cases. There are 1 to 5
variables per case.
I need to calculate the mean of the means of these 1 to 5 variables for each
of my 62 cases.
-----------------------------------------
A possible code for one case with 3 variables looks like this:
sum sd0032i1
local x=r(mean)
sum sd0032i3
local y=r(mean)
sum sd0032i4
local z=r(mean)
gen msd0032=(`x’+`y’+`z’)/3
--------------------------------------
The 3rd to 6th letter of the variable names is identical for the variables
of each case, the last letter distinguishes the 1 to 5 variables with an
ascending order but unfortunately sometimes with "gaps" like in the case
above.
My problem is: how can I generalise this - or an equivalent - code to be
repeated 62 times with a varying number of variables?
I would be grateful for hints to solve this problem!
Dietrich.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dietrich Drüner
Schneckenburgstr. 24
D - 78467 Konstanz
Tel. (+49) - 7531 - 698003
Fax (+49) - 1212 - 522970813
Mob.(Inland): (+49) - 177 - 6334099
Mob.(Ausland):(+49) - 162 - 7679952
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/