Page 1 of 1
Count Variable in Panel Time Series Workfile
Posted: Tue Dec 17, 2013 9:21 am
by backhaum
Dear all,
here's my problem I have been trying to solve for some time now. Maybe someone might be able to help:
I have a panel workfile with different cross-sections. I want to to generate a count variable that indicates the number of observation of the cross-section.
Here is my workfile structure:
A B
1 1
1 2
2 1
2 2
2 3
3 1
4 1
4 2
So I want to generate B. Any suggestions????
Thank you so much for your help.
Best regards,
Max
Re: Count Variable in Panel Time Series Workfile
Posted: Tue Dec 17, 2013 9:38 am
by EViews Glenn
I'm away from the docs right now, but I think you can simply use the @obsid keyword, as in
I'll double check this when I get into the office.
Re: Count Variable in Panel Time Series Workfile
Posted: Tue Dec 17, 2013 9:41 am
by backhaum
Dear Glenn,
thank you for the quick reply!!
But I do not think this will solve my problem.
Although @obsid counts the number of the observation in each cross-section, I do not want to count each observation.
This is also indicated in the example below, especially because I want to count only a specific subsample (Colum B):
A B C
1 1 1
1 0 0
1 1 2
2 1 1
2 1 2
3 0 0
4 1 1
4 1 2
4 1 3
Where A = Cross-Section ID, B = condition, C = count variable, I am trying to generate.
Any suggestions?
Best regards
Re: Count Variable in Panel Time Series Workfile
Posted: Tue Dec 17, 2013 9:45 am
by EViews Gareth
Did you try what Glenn suggested? It does what you want...
Ah, you edited your post to add extra conditions...
Re: Count Variable in Panel Time Series Workfile
Posted: Tue Dec 17, 2013 9:52 am
by backhaum
Dear Gareth,
yes, it actually does count the number of obs in each cross-section but I only want to count them based on a specific condition.
Excuse me for the confusion, I thought I start with the simple problem, but this does not really solve my issue.
Thank you again for the support.
Max
Re: Count Variable in Panel Time Series Workfile
Posted: Tue Dec 17, 2013 10:02 am
by EViews Gareth
Code: Select all
series cc = @recode(@obsid=1, 1, @recode(b=0, cc(-1), cc(-1)+1))
cc = @recode(b=0, 0, cc)
Re: Count Variable in Panel Time Series Workfile
Posted: Thu Dec 19, 2013 2:16 am
by backhaum
Dear Gareth,
it works !!! Thank you very much...
Best regards
Max