How about:
<data>
<xsl:variable name="var1" select="'SOME_DATA1'" />
<xsl:text><xsl:value-of select="var1"/></xsl:text>
<xsl:if test="'some_condition'">
<xsl:variable name="var2" >
<xsl:value-of select="'SOME_DATA2'"/>
</xsl:variable>
<xsl:text><xsl:value-of select="var2"/></xsl:text>
</xsl:if>
</data>
The way you wrote it, var2 does not exist after the /xsl:if.
Another way would be like this:
<xsl:variable name="var1" select="'SOME_DATA1'" />
<xsl:variable name="var2" >
<xsl:if test="'some_condition'">
<xsl:value-of select="'SOME_DATA2'"/>
</xsl:if>
</xsl:variable>
<data> <!-- Use var1 and var2 here --> </data>
In this way, you have a var2 regarardeless of the condition, but it is empty if the condition is false. And you still have the variable after the condition.