Hello,
in Eviews there are many functions to make cumulative sums and to make statsby, but I cannot solve the kind of "cumulative by" problem. The problem is to have a series with counted occurence of specific values of the other series, within each ID variable separately.
Please find attached the workfile, it is unstructured/undated workfile, and there:
- CONVERSION_ID is our variable, that we want to group by
- INTERACTION_CHANNEL is the variable with categories, that we want to calculate occurence of, within the Conversion IDs
- INTERACTION_DATE_TIME is the exact date of each instance of interaction channel - maybe it will be helpful to have it
- OCCURENCE is what we want to achieve - I fill in the values manually, to ilustrate you how it should look like.
Is it possible to automize it smartly in Eviews (v. 8.1) ?
thanks
adrian
Cumulative sum by series - how do it quickly?
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
Cumulative sum by series - how do it quickly?
- Attachments
-
- cumulative sum problem.wf1
- (10.53 KiB) Downloaded 402 times
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Cumulative sum by series - how do it quickly?
Probably an easier way, but:
Code: Select all
vector ids = @uniquevals(conversion_id)
svector chns = @uniquevals(interaction_channel)
for !i=1 to @rows(ids)
for !j=1 to @rows(chns)
%chn = chns(!j)
smpl if conversion_id = ids(!i) and interaction_channel=%chn
series temp = 1
series occ = @cumsum(temp)
delete temp
next
next
smpl @all
Follow us on Twitter @IHSEViews
Re: Cumulative sum by series - how do it quickly?
EViews Gareth wrote:Probably an easier way, but:Code: Select all
vector ids = @uniquevals(conversion_id)
svector chns = @uniquevals(interaction_channel)
for !i=1 to @rows(ids)
for !j=1 to @rows(chns)
%chn = chns(!j)
smpl if conversion_id = ids(!i) and interaction_channel=%chn
series temp = 1
series occ = @cumsum(temp)
delete temp
next
next
smpl @all
Okay, it's quite similar to what I've tried, not too quick when I have thousands of conversion ids, but thanks. Maybe it would be good idea to take such a function into consideration in the upcoming Eviews updates.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13317
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Cumulative sum by series - how do it quickly?
EViews Glenn came up with a, possibly, faster solution:
Code: Select all
series id = @trend+1
pagestruct(create) conversion_id interaction_channel
series occ=@trend+1
pagestruct(none)
sort id
Follow us on Twitter @IHSEViews
-
- EViews Developer
- Posts: 2672
- Joined: Wed Oct 15, 2008 9:17 am
Re: Cumulative sum by series - how do it quickly?
I think you need to recode at the end to handle the blanks in interaction_channel:
Code: Select all
occ = @recode(interaction_channel="", NA, occ)
Re: Cumulative sum by series - how do it quickly?
Yeah, making this pagestruct and @trend is great, thank you very much guys!
-
- Posts: 4
- Joined: Thu Aug 19, 2021 10:45 pm
Re: Cumulative sum by series - how do it quickly?
Hi EViews team,
Sorry to have a follow up question on a post 6 years ago. I got an exact issue that ardian_d came across. Gareth and Glenn's solutions both work well on the issue until more recently I got a big dataset that involves 3 million observations. Eviews couldn't do the "pagestruct" as the group variable consists of 1.2 million groups. That exceeds the limit of "pagestruct"; whereas the loop from Gareth will take me around 13 days to complete the looping. For the time being, I try R; and use dplyr mydata %>% group_by(group, obs) %>% mutate(myorder = 1:n()) to complete the task. But I would be grateful if I can have a solution to program that in Eviews, to save some hiccups in switching in between software.
Sorry to have a follow up question on a post 6 years ago. I got an exact issue that ardian_d came across. Gareth and Glenn's solutions both work well on the issue until more recently I got a big dataset that involves 3 million observations. Eviews couldn't do the "pagestruct" as the group variable consists of 1.2 million groups. That exceeds the limit of "pagestruct"; whereas the loop from Gareth will take me around 13 days to complete the looping. For the time being, I try R; and use dplyr mydata %>% group_by(group, obs) %>% mutate(myorder = 1:n()) to complete the task. But I would be grateful if I can have a solution to program that in Eviews, to save some hiccups in switching in between software.
Who is online
Users browsing this forum: No registered users and 22 guests