My data is organised as following hierarchy:
1843 subjects, each with 9 sets of questions across 4 alternatives.
For each set of 4 alternatives I want to find the highest value of one variable (if it is present). So everything I do I want to do on each set of 4 alternatives.
for !i=1 to 1843
for !j= 1 to 9
for !k=1 to 4
smpl if !i=id and !j =survey_qnumber and !k=alternative
smpl if type1=1
series wildp=@maxsby(price, alternative)
next
next
next
However, this returns the highest price across all 1843 rows, not the highest price in each subset of 4 alternatives. I know my programming is pretty rusty, so if anyone can identify what I'm doing wrong and what would work instead, I'd love a few hints.
Hints for "for" loop in nested hierarchy
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13319
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Hints for "for" loop in nested hierarchy
You'll need to be more specific as to how the data are set up in EViews.
Does not describe data in EViews.
1843 subjects, each with 9 sets of questions across 4 alternatives.
Does not describe data in EViews.
Follow us on Twitter @IHSEViews
Re: Hints for "for" loop in nested hierarchy
Ah, sorry.
I import the data from a csv file, as unstructured data.
Screenshot added.
ID is the highest level, this branches into sruvey_qnumber (1-9) and this branches into 1-4 alternatives.
My goal is to collate and aggregate each of the 4 alternative rows into one row, using select variable values across the 4 rows. So for instance, I want the maximum price (column w) for each type 1 (column H) reduced to a single row of data at the end of the program.
TIA, B
I import the data from a csv file, as unstructured data.
Screenshot added.
ID is the highest level, this branches into sruvey_qnumber (1-9) and this branches into 1-4 alternatives.
My goal is to collate and aggregate each of the 4 alternative rows into one row, using select variable values across the 4 rows. So for instance, I want the maximum price (column w) for each type 1 (column H) reduced to a single row of data at the end of the program.
TIA, B
Last edited by Chthoniid on Thu Oct 24, 2019 9:21 pm, edited 2 times in total.
Re: Hints for "for" loop in nested hierarchy
Got it all figured
Who is online
Users browsing this forum: No registered users and 55 guests