awk loop using array:wish to store array values from loop for use outside loop

Here's my code:

awk -F '[ : ]'  'NR==FNR {
    if (/time/ && $5>10)
        A[++N]=$2" "$3":"$4":"($5-01)
    else if (/time/ && $5<01)
        A[++N]=$2" "$3":"$4-01":"(59-$5)
    else if (/time/ && $5<=10)
        A[++N]=$2" "$3":"$4":0"($5-01)
    else if (/close/) {
        B[FNR]=0
        n1=n2;
        n2=FNR;
    }
else if (/^sta EP/) {
match($0,/^sta EP([0-9]*)/,a)
snr=a[1] 
        if (snr != prev) {
            B[n1]=1
            B[n2]=1
        }
        prev=snr
    }
    next
}

FNR==1 {
    B[n1]=1; B[n2]=1
}
/time/ {
    M++
}
/close/ {
    if (B[FNR]) {
        $0=$1" ""EP"snr" ""12/31/2013 23:59:59"
done
    }
else if ((M%2) == 0 || (M%2) == 1) {
        NF=3
        $0=$0" "A[M+1]
    }
}
{print}' EAST_comprehensive2013_bfile.txt EAST_comprehensive2013_bfile.txt >> neen.txt

What I would like to do is store each iteration value of the variable snr currently defined as:

snr=a[1] 

to be used in the following line:

$0=$1" ""EP"snr" ""12/31/2013 23:59:59"

So that when it goes through each of the matched ^sta EP values it uses the correct value of the loop to insert into the above line. Does this make sense? Currently, since I'm not sure how to store these values it only retains the last value of the loop, which makes sense because I'm not telling it otherwise. My question is how do I store that value and then call it later in the line above? 'a' is already an array from the match statement, but I'm not sure if I need to make snr also be an array, or what to do. Any help would be greatly appreciated! Thanks in advance!

Please show us your sample input and expected output.

I don't need any help modifying the rest of the awk script that I have posted, just the part of storing the variable. Basically it runs through a text file (example below) and for the last close statement for each station (EP*) it changes the close statement to

close EP00 12/31/2013 23:59:59

and for the next block of text for the next station it would then change the last close statement to:

close EP01 12/31/2013 23:59:59

etc, for all of the stations that are within the text file. I would like the variable 'snr' to retain the station name for each iteration through the loop, instead of only retaining the last station name, so that as it gets to the last close statement for each station it can use the correct station name.

Here's an excerpt from the text file below:

----------------------------------------- 
sta EP00  
time 10/23/2013 20:10:17 
sensor trillium_240_2 0 583 
add 
close sensor trillium_240_2 10/23/2013 20:10:17  

sensor trillium_120 0 279 
add 
close sensor trillium_120 10/23/2013 20:10:35
 --------------------------------------------- 
sta EP00 
time 10/28/2013 20:20:28 
sensor trillium_240_2 0 583 
add 
close sensor trillium_240_2 10/28/2013 20:20:28

sensor trillium_120 0 268 
add 
close sensor trillium_120 10/28/2013 20:20:45
 ---------------------------------------------- 
sta EP01
time 10/23/2013 20:10:17 
sensor trillium_240_2 0 583 
add 
close sensor trillium_240_2 10/23/2013 20:10:17  

sensor trillium_120 0 279 
add 
close sensor trillium_120 10/23/2013 20:10:35 
--------------------------------------------- 
sta EP01 
time 10/28/2013 20:20:28 
sensor trillium_240_2 0 585 
add 
close sensor trillium_240_2 10/28/2013 20:20:28

sensor trillium_120 0 280
add 
close sensor trillium_120 10/28/2013 20:20:28 
----------------------------------------------------------

It's important to note that there are more than two entries for each station, i.e., there can be up to 'n' entries, and one station block contains 2 close statements. For the sake of clarity I broke up each complete station block with the dashed lines.

The expected output would be to change the last station block's two close statements to read, if we used EP00 as the station for example

close EP00 12/31/2013 23:59:59

I had another question posted on another issue related to helping with this code, which have all been resolved from the above code example I have given. Now I just need to know how to store the value of 'snr' so I can use it in the last close statements for each station. Hopefully this helps clarify @akshay hegde