Combining duplicate observations

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

zx00xz
Posts: 3
Joined: Mon May 12, 2014 6:22 am

Combining duplicate observations

Postby zx00xz » 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!

startz
Non-normality and collinearity are NOT problems!
Posts: 3798
Joined: Wed Sep 17, 2008 2:25 pm

Re: Combining duplicate observations

Postby startz » Mon May 12, 2014 7:50 am

check out @meansby

zx00xz
Posts: 3
Joined: Mon May 12, 2014 6:22 am

Re: Combining duplicate observations

Postby zx00xz » Tue May 13, 2014 3:13 am

Thank you so much!

This works to the point that I now have the following output:

Obs | Series X | Series Y
#1 | 1 | 1.5
#2 | 1 | 1.5
#3 | 2 | 3.5
#4 | 2 | 3.5
#5 | 3 | 5.5
#6 | 3 | 5.5

The final thing that I would like to do is remove the duplicate Series X values, to hopefully get:

Obs | Series X | Series Y
#1 | 1 | 1.5
#2 | 2 | 3.5
#3 | 3 | 5.5

@uniquevals(series_x) unfortunately only displays the unique values for Series X. Using this function on a group gives an error. How can I include the related Series Y values?

Thank you in advance!

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Combining duplicate observations

Postby EViews Glenn » Tue May 13, 2014 7:27 am

You should create a new EViews page containing the identifiers from the original page (when you click on the new page tab on the bottom of your workfile page, there should be an option to create a new page from identifiers). Then when you copy/link the original series into the new page, EViews will combine the duplicate values to create a unique value for each identifier (the default is to use the mean is what you want).

zx00xz
Posts: 3
Joined: Mon May 12, 2014 6:22 am

Re: Combining duplicate observations

Postby zx00xz » Wed May 14, 2014 4:59 am

Thanks!


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests