Save scalars in a vector

For questions regarding programming in the EViews programming language.

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

lpando08
Posts: 29
Joined: Tue Apr 03, 2018 1:13 pm

Save scalars in a vector

Postby lpando08 » Wed Apr 18, 2018 7:22 am

Hello,

I have this loop:

for !i=10 to 100 step 10
scalar ssrt_!i=sum_ssr_hdebt_!i+sum_ssr_ldebt_!i
next

I would like to know how to save the scalars that it generate, I mean ssrt_10, ssrt_11,etc in a vector and then find the minimun of that vector.

Thank you for your help.

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

Re: Save scalars in a vector

Postby EViews Gareth » Wed Apr 18, 2018 7:24 am

Code: Select all

vector(10) a
for !i=10 to 100 step 10
!j = !i/10
a(!j)=sum_ssr_hdebt_!i+sum_ssr_ldebt_!i
next
Follow us on Twitter @IHSEViews

lpando08
Posts: 29
Joined: Tue Apr 03, 2018 1:13 pm

Re: Save scalars in a vector

Postby lpando08 » Wed Apr 18, 2018 7:36 am

And is there a way to indentify which is the minimun value of that vector, I mean to identify which scalar ssrt_!i is the minimun value of that vector?

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

Re: Save scalars in a vector

Postby EViews Gareth » Wed Apr 18, 2018 8:10 am

Follow us on Twitter @IHSEViews

lpando08
Posts: 29
Joined: Tue Apr 03, 2018 1:13 pm

Re: Save scalars in a vector

Postby lpando08 » Wed Apr 18, 2018 9:22 am

And if I want to run the loop from 1 to 100 without the step and save the 91 values in a vector? How I could conduct that?

vector(91) a
for !i=10 to 100
for !j=1 to 91
a(!j)=ssrt_!i
next
next

I have run something like this but it gives me the same value (the last ssrt_!i of the loop) in all the rows of the vector.


Return to “Programming”

Who is online

Users browsing this forum: Google [Bot] and 36 guests