Syntax error in nested loops
Posted: Mon May 09, 2016 11:20 am
Good day.
I have been trying to edit some data series in a set of nested "For" loops. I wish to copy data from a specified date through to the end of the sample. Some of the data series in the groups are 'NA', which is not a problem for me. The code I am using is as follows:
Essentially I am looping through several groups (called "Basins"), each of which has between 1 and 9 data series. I have established a vector "Final_Date" that identifies the last date for which any data is present in the group. I wish to then copy the values at that date (@elem(series, Final_Date)) to all the remaining months of my sample.
When I run the program I am confronted with the error message "Syntax error in control statement in "Next"". I have browsed through the forum boards & stared in stupefaction for an absurdly long time at my code, without enlightenment. Would anybody be able to tell me what I have done incorrectly?
Thank you.
I have been trying to edit some data series in a set of nested "For" loops. I wish to copy data from a specified date through to the end of the sample. Some of the data series in the groups are 'NA', which is not a problem for me. The code I am using is as follows:
Code: Select all
For !k = 1 to !NBasins ' For each of the Basins
%S = basin_id(!K) ' Grab the Kth ID
%Z = final_date(!k) ' Identify the date of the final element in the series
%name = "g_stshare_{%s}" ' For each grouped set of state shares
For !i=1 to {%name}.@count ' For each column series in the group
%st = {%name}.@seriesname(!i) ' Get the series' name
{%st}.fill(s) @elem({%st}, {%Z} ) ' Fill the series with the observation corresponding to the final date
Next ' Go to the next column in the group
Next ' Go to the next Basin
When I run the program I am confronted with the error message "Syntax error in control statement in "Next"". I have browsed through the forum boards & stared in stupefaction for an absurdly long time at my code, without enlightenment. Would anybody be able to tell me what I have done incorrectly?
Thank you.