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.
Observation IDs within a sample
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Observation IDs within a sample
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
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
That assumes the observations in the sample are consecutive.
Re: Observation IDs within a sample
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:
I didn't think about what would happen with non-consecutive observations in the sample. That would definitely add some complexity.
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
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13603
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Observation IDs within a sample
This works in the more general, non-consecutive case:
Since ser will only be equal to 1 for observations in the current sample, the cumulation works.
Code: Select all
series ser = 1
series id = @cumsum(ser)
Who is online
Users browsing this forum: No registered users and 2 guests
