Loops to fill a table

For questions regarding programming in the EViews programming language.

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

eviews_5
Posts: 7
Joined: Tue Aug 17, 2021 10:46 am

Loops to fill a table

Postby eviews_5 » Tue Aug 17, 2021 11:51 am

Hi, I'm trying to fill in a table, "cqestimates" with the code below. When I look at the values in the table it fills each column with the same number. It fills it with the correct value for cell (2,18), but in all of columns instead of just column 18.

Code: Select all

%quarter = "2021Q3"

group elements a b c d e f g h i j k l m n o p q

for !columns =2 to 18
for !i =1 to elements.@count
%val_name = elements.@seriesname(!i)
cqestimates(2, !columns) = @elem({%val_name}, %quarter)
next
next

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

Re: Loops to fill a table

Postby EViews Gareth » Tue Aug 17, 2021 1:51 pm

Code: Select all

for !i =1 to elements.@count
%val_name = elements.@seriesname(!i)
cqestimates(2, !i) = @elem({%val_name}, %quarter)
next
Follow us on Twitter @IHSEViews

eviews_5
Posts: 7
Joined: Tue Aug 17, 2021 10:46 am

Re: Loops to fill a table

Postby eviews_5 » Wed Aug 18, 2021 8:46 am

Great, thank you.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 26 guests