Hi:
I am guessing that the code snippet we see is not the complete code you are using. When any code you post has < or > symbols, the forum posting software frequently truncates the post because it tries to interpret the < and > as HTML tags.
The way around it is to use < or > (ampersand-lt-semicolon or ampersand-gt-semicolon) for purposes of posting the code.
However, before you go to all that effort to modify your code, your best bet is to open a ticket with Tech Support and provide them information or code about:
1) how are you invoking the tagset template: SAS XML Libname Engine or as ODS TAGSETS.?????? invocation. The method by which you invoke the tagset template does make a difference because the events could be different if generated for procedure output versus generated for data.
2) provide them with a sample copy of the SAS data set which is input to your process
3) provide them with a good copy of the XML you need to replicate
4) provide them the code you plan/want to use to invoke the tagset template.
I believe the solution for the counter issue will depend on how your count gets incremented. It will depend on where the incrementing is happening - -if it happens within the tagset template process, then you will need an event to trigger the incrementing of the variable. If it happens within a DATA step program, then you will likely need to retain the counter variable across iterations of the DATA step.
Tech Support is your best resource for help on this front.
cynthia