for loop with skipped values

For questions regarding programming in the EViews programming language.

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

remuct
Posts: 27
Joined: Fri May 12, 2017 6:47 am

for loop with skipped values

Postby remuct » Thu Oct 21, 2021 10:26 am

Hello,
I am wandering if there is a possibility of executing a for loop by skipping some values.
For example, I have 100 variables v1, v2,...v100 and I want to set them all to zero except v52 and v80. Is there a way of doing this within a "restricted" for loop?
Thank you

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

Re: for loop with skipped values

Postby EViews Gareth » Thu Oct 21, 2021 12:17 pm

Put an if statement inside the loop
Follow us on Twitter @IHSEViews

remuct
Posts: 27
Joined: Fri May 12, 2017 6:47 am

Re: for loop with skipped values

Postby remuct » Thu Oct 21, 2021 2:53 pm

This was so simple I didn't think doing this way. Thank you!


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 19 guests