Syntax Error in string for loop

For questions regarding programming in the EViews programming language.

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

Benlam1
Posts: 2
Joined: Thu Jun 07, 2012 2:07 am

Syntax Error in string for loop

Postby Benlam1 » Thu Jun 07, 2012 2:12 am

Hi,

I have written a program which should allow me to test a number of extra variables when added to a base regression specification, returning the t values for each specification when estimated in a matrix. It sometimes seems to work, but is very sensitive, and often comes up with the following error: 'Syntax Error in for %k [then a list of the variable names]' Do you have any idea why this might be?

Code: Select all

%dep = "" ' variable to store name of dependent variable %regs = "c " ' variable to store list of regressors. Default is "c" for a constant. %extra ="" 'variable to store test regressors !result = 0 ' variable that will track the result of dialogs. -1 indicates user hit Cancel. 0 Indicates user hit OK. !result = @uidialog("Caption", "Additional Regressor Tester", "edit", %dep,"Enter the dependent variable", 300, "edit", %regs, "Enter the list of initial regressors", 10000, "edit", %extra,"Enter the list of regressors you would like to test",10000) ' put up an Edit dialog asking for dependent variable. if !result=-1 then 'if user cancelled, then stop program stop endif string a = %extra group q_exreg group q_reg !j=0 for %k {%extra} q_exreg.add {%k} next for %l {%regs} q_reg.add {%l} next matrix(q_reg.@count+1, q_exreg.@count) q_tstat for %i {%extra} !j = !j + 1 equation q_eqa_{%i}.ls {%dep} {%regs} {%i} colplace(q_tstat, q_eqa_{%i}.@tstats, !j) next
Your help is much appreciated!

Thanks,

Ben

Benlam1
Posts: 2
Joined: Thu Jun 07, 2012 2:07 am

Re: Syntax Error in string for loop

Postby Benlam1 » Thu Jun 07, 2012 6:19 am

Hi,

An update on the problem. The 'syntax error' only occurs when I paste in all the variables at once when prompted to do so by the uidialog box. If I paste them in individually this is not an issue. I'm guessing it is something to do with the blank spaces etc. which are getting pasted in along with the variable names. Is there a way I can make this procedure robust to this so that errors don't occur when I am pasting in large lists of variable names? (It won't be good enough to paste in variables one by one since the point of the program is to reduce the time required to find significant variables).

Thanks again for your help.

Ben

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

Re: Syntax Error in string for loop

Postby EViews Gareth » Thu Jun 07, 2012 8:11 am

I've run the program a few times (nice job by the way), and haven't had a syntax error yet. How are you pasting the variables? (or, where are you copying them from?)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests