## defining multiple groups in nested loop with equality tests

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

wicker6m
Posts: 2
Joined: Tue Jul 01, 2014 12:39 am

### defining multiple groups in nested loop with equality tests

Hello I am new to the forum and completely new to Eviews programming. I have two series of data (call them series1 and series2) as well as a series specifying a year (year) and a series specifying an industry (industry). For each year and each industry, I would like to perform an equality test between the median of that specific set of series1 and series2 (10 years times 9 industries = 90 sets). It seems that what I need to do is create a nested for loop that creates two new series for each of these sets, creates a group, and proceeds to run and record an equality test. So something like this (using pseudo-code):

For i = 2004 through 2013
For j = 1 through 10 (referring to the industry)
newseries1 = series1 if year = i AND industry = j
newseries2 = series2 if year = i AND industry = j
newgroup = newseries1 and newseries2
run equality test for medians between newseries1 and newseries2 in newgroup (testbtw function)
record full results of median equality test
End For
End For
.
I can easily assign a number 1 through 90 to each "industry year" if that is simpler than creating a nested for loop. Any comments would be greatly appreciated. Thank you

**EDIT: I should add that I am using Eviews 8**

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

### Re: defining multiple groups in nested loop with equality te

Something like:

Code: Select all

`group g series1 series2for !i=2004 to 2013for !j = 1 to 10smpl if year=!i and industry=!jfreeze(tab_!i_!j) g.testbtw(med)nextnext`

wicker6m
Posts: 2
Joined: Tue Jul 01, 2014 12:39 am

### Re: defining multiple groups in nested loop with equality te

This is perfect and exactly what I was looking for. Can't thank you enough.
Is there an additional line of code I can add that could compile all of these output tabs (vertically) into a single output sheet that I can then manually import into excel?

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

### Re: defining multiple groups in nested loop with equality te

Code: Select all

`spool sgroup g series1 series2for !i=2004 to 2013for !j = 1 to 10smpl if year=!i and industry=!jfreeze(tab_!i_!j) g.testbtw(med)s.append tab_!i_!jnextnexts.save(t=csv) myfile.csv`

COM446
Posts: 12
Joined: Wed Jul 08, 2015 2:10 pm

### two-sample equality tests

Hi, I have a series x and a classification variable 'hour' with value 1 or 2. How to write a program to test the difference between the mean, median and standard deviation for the two samples. I understand that two-sample tests can be done interactively but I have many series. How to write a program for the tests? Thanks a lot for your help. Howard

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