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
Count Variable in Panel Time Series Workfile
Moderators: EViews Gareth, EViews Moderator
-
- EViews Developer
- Posts: 2672
- Joined: Wed Oct 15, 2008 9:17 am
Re: Count Variable in Panel Time Series Workfile
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.
Code: Select all
series b = @obsid
I'll double check this when I get into the office.
Re: Count Variable in Panel Time Series Workfile
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
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
Last edited by backhaum on Tue Dec 17, 2013 9:50 am, edited 2 times in total.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Count Variable in Panel Time Series Workfile
Did you try what Glenn suggested? It does what you want...
Ah, you edited your post to add extra conditions...
Ah, you edited your post to add extra conditions...
Follow us on Twitter @IHSEViews
Re: Count Variable in Panel Time Series Workfile
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
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
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Count Variable in Panel Time Series Workfile
Code: Select all
series cc = @recode(@obsid=1, 1, @recode(b=0, cc(-1), cc(-1)+1))
cc = @recode(b=0, 0, cc)
Follow us on Twitter @IHSEViews
Re: Count Variable in Panel Time Series Workfile
Dear Gareth,
it works !!! Thank you very much...
Best regards
Max
it works !!! Thank you very much...
Best regards
Max
Return to “General Information and Tips and Tricks”
Who is online
Users browsing this forum: No registered users and 20 guests