for loop with strings and alpha series

For questions regarding programming in the EViews programming language.

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

bjoern
Posts: 5
Joined: Mon Mar 15, 2010 6:04 am

for loop with strings and alpha series

Postby bjoern » Thu Feb 13, 2025 9:41 am

Hello

I would like to create new alpha variables with the for loop. However, this is prevented by the quotation marks. For example:

This code works fine:
for %k %j 1 20 2 30 3 40
series country{%k}={%j}
next

But I would like to have the names of the countries as string variables
alpha country1="belgium”
alpha country2="germany”
alpha country3="italy”

This code does not work:
for %k %j 1 belgium 2 germany 3 italy
alpha country{%k}="{%j}"
next

This code does not work either:
for %k %j 1 "belgium" 2 "germany" 3 "italy"
alpha country{%k}={%j}
next

And this code doesn't work either:
for %k %j 1 {"belgium"} 2 {"germany"} 3 {"italy"}
alpha country{%k}={%j}
next

Is there a solution that I am overlooking?

Thank you very much for your help!

Best regards,
Björn

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

Re: for loop with strings and alpha series

Postby EViews Gareth » Thu Feb 13, 2025 10:05 am

Code: Select all

for %k %j 1 belgium 2 germany 3 italy alpha country{%k}=%j next


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests