Count Variable in Panel Time Series Workfile

For requesting general information about EViews, sharing your own tips and tricks, and information on EViews training or guides.

Moderators: EViews Gareth, EViews Moderator

backhaum
Posts: 11
Joined: Fri Nov 08, 2013 3:58 am

Count Variable in Panel Time Series Workfile

Postby backhaum » Tue Dec 17, 2013 9:21 am

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

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

Re: Count Variable in Panel Time Series Workfile

Postby EViews Glenn » Tue Dec 17, 2013 9:38 am

I'm away from the docs right now, but I think you can simply use the @obsid keyword, as in

Code: Select all

series b = @obsid

I'll double check this when I get into the office.

backhaum
Posts: 11
Joined: Fri Nov 08, 2013 3:58 am

Re: Count Variable in Panel Time Series Workfile

Postby backhaum » Tue Dec 17, 2013 9:41 am

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
Last edited by backhaum on Tue Dec 17, 2013 9:50 am, edited 2 times in total.

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

Re: Count Variable in Panel Time Series Workfile

Postby EViews Gareth » Tue Dec 17, 2013 9:45 am

Did you try what Glenn suggested? It does what you want...

Ah, you edited your post to add extra conditions...
Follow us on Twitter @IHSEViews

backhaum
Posts: 11
Joined: Fri Nov 08, 2013 3:58 am

Re: Count Variable in Panel Time Series Workfile

Postby backhaum » Tue Dec 17, 2013 9:52 am

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

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

Re: Count Variable in Panel Time Series Workfile

Postby EViews Gareth » Tue Dec 17, 2013 10:02 am

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

backhaum
Posts: 11
Joined: Fri Nov 08, 2013 3:58 am

Re: Count Variable in Panel Time Series Workfile

Postby backhaum » Thu Dec 19, 2013 2:16 am

Dear Gareth,

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 1 guest