Observation IDs within a sample

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

jthodge
Posts: 77
Joined: Tue Oct 21, 2008 5:52 am

Observation IDs within a sample

Postby jthodge » Mon May 09, 2011 8:56 am

Is there a way to create a series for an unstructured workfile that shows the relative observation IDs within a sample?

The @OBSNUM and @OBSID functions give the absolute observation IDs relative to the entire workfile range.

I'd like to know the observation IDs relative to the first observation within the sample.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Observation IDs within a sample

Postby EViews Gareth » Mon May 09, 2011 9:01 am

I cannot think of an easy way to get it, no :(.

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

Re: Observation IDs within a sample

Postby startz » Mon May 09, 2011 9:10 am

Something like

Code: Select all

series foo = @obsid - @min(@obsid)

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Observation IDs within a sample

Postby EViews Gareth » Mon May 09, 2011 9:14 am

That assumes the observations in the sample are consecutive.

jthodge
Posts: 77
Joined: Tue Oct 21, 2008 5:52 am

Re: Observation IDs within a sample

Postby jthodge » Mon May 09, 2011 9:41 am

Startz's idea should work for me since the observations within my sample are consecutive.

However, to clarify, I think you first need to set the sample in the workfile, of course, and you need to add 1 so that the first obs id within the sample is 1 and not 0:

Code: Select all

smpl ... series foo = @obsid - @min(@obsid) + 1
I didn't think about what would happen with non-consecutive observations in the sample. That would definitely add some complexity.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13603
Joined: Tue Sep 16, 2008 5:38 pm

Re: Observation IDs within a sample

Postby EViews Gareth » Mon May 09, 2011 9:44 am

This works in the more general, non-consecutive case:

Code: Select all

series ser = 1 series id = @cumsum(ser)
Since ser will only be equal to 1 for observations in the current sample, the cumulation works.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests