Hi,
I have a dummy variable that is either 1 or NA called "below50". I want to create a series that counts how many consecutive 1's there are and returns to 0 when it encounters an NA.
EX:
below50 CUM
NA 0
NA 0
NA 0
1 1
1 2
1 3
1 4
NA 0
NA 0
NA 0
1 1
NA 0
As a second job I would also like to see this CUM series count in reverse so that if below50 is NA, it counts how many consecutive NAs there are but incrementing from -1, -2, -3 etc...
Ex:
EX:
below50 CUM2
NA -1
NA -2
NA -3
1 1
1 2
1 3
1 4
NA -1
NA -2
NA -3
1 1
NA -1
Count number of dummy variables
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
-
- EViews Developer
- Posts: 564
- Joined: Thu Apr 25, 2013 7:48 pm
Re: Count number of dummy variables
Hello,
Try these...
Try these...
Code: Select all
series cum = @recode(@isna(below50), 0, @nan(cum(-1), 0) + 1)
series cum2 = @recode(@eqna(below50,below50(-1)), @nan(cum2(-1), 0), 0) + @recode(@isna(below50), -1, 1)
Who is online
Users browsing this forum: No registered users and 15 guests