Combining duplicate observations
Posted: Mon May 12, 2014 7:26 am
Hello all,
I am new to Eviews and I was wondering if I could do the following. Suppose I have imported the following dataset into Eviews 8:
Obs | Series X | Series Y
#1 | 1 | 1
#2 | 1 | 2
#3 | 2 | 3
#4 | 2 | 4
#5 | 3 | 5
#6 | 3 | 6
For every unique value of Series X I would like to have all of its Series Y values combined (i.e. their mean), such as in the table below:
Obs | Series X | Series Y
#1 | 1 | 1.5
#2 | 2 | 3.5
#3 | 3 | 5.5
I have tried using @uniquevals(series_x) to get all the unique values of Series X. However, the resulting vector doesn't show any information on the values of Series Y. What I would like to do is combine all values of Series Y for each related unique value of Series X (of which there are duplicates). This can be done manually by specifying the sample (i.e. smpl if series_x=1) and then consulting descriptive statistics, however with a larger dataset this quickly becomes cumbersome (I am looking at approximately 1000 unique Series X values). I am looking for a similar function as AVERAGEIF in Excel, however I can't use Excel for other unrelated reasons. Can this be done in an efficient way?
Thank you in advance!
I am new to Eviews and I was wondering if I could do the following. Suppose I have imported the following dataset into Eviews 8:
Obs | Series X | Series Y
#1 | 1 | 1
#2 | 1 | 2
#3 | 2 | 3
#4 | 2 | 4
#5 | 3 | 5
#6 | 3 | 6
For every unique value of Series X I would like to have all of its Series Y values combined (i.e. their mean), such as in the table below:
Obs | Series X | Series Y
#1 | 1 | 1.5
#2 | 2 | 3.5
#3 | 3 | 5.5
I have tried using @uniquevals(series_x) to get all the unique values of Series X. However, the resulting vector doesn't show any information on the values of Series Y. What I would like to do is combine all values of Series Y for each related unique value of Series X (of which there are duplicates). This can be done manually by specifying the sample (i.e. smpl if series_x=1) and then consulting descriptive statistics, however with a larger dataset this quickly becomes cumbersome (I am looking at approximately 1000 unique Series X values). I am looking for a similar function as AVERAGEIF in Excel, however I can't use Excel for other unrelated reasons. Can this be done in an efficient way?
Thank you in advance!