XSLT is a functional language, and the methods that you used in the past with procedural languages don't always apply. In particular, you can't update variables, and you can't do anything when processing one item in a for loop that affects the way "subsequent" items are processed, because there's no concept of "subsequent" - you have to imagine they are all processed in parallel.
If the number of rows is small, you can do
<xsl:if test="not(state = preceding-sibling::row/state)"
If you're using XSLT 2.0 you probably want to be using xsl:for-each-group or the distinct-values() function.
If you're using XSLT 1.0 (and there's no way you can upgrade) then look at the various grouping techniques discussed at
http://www.jenitennison.com/xslt/grouping. They aren't easy, but you get the hang of them.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference