<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: What is the best way to implement this logic? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-best-way-to-implement-this-logic/m-p/122457#M25123</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data trend;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input tag $ @@;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length _tag $8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain _tag ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _tag=coalescec(tag,_tag);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if missing(tag) then tag=ifc(_tag='tr-tr','tr',_tag);&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop _tag;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp; tr-c . . . tr-c tr-tr . .&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Nov 2012 19:58:53 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-11-09T19:58:53Z</dc:date>
    <item>
      <title>What is the best way to implement this logic?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-best-way-to-implement-this-logic/m-p/122456#M25122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a data set like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data trend;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input tag $ @@;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp; tr-c . . . tr-c tr-tr . .&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this data set, I like to assign the missing tag values as the previous value except that after the tag value become the 'tr-tr', all the following missing values should be 'tr'. To make it clear, I like the final data set look like this:&lt;/P&gt;&lt;P&gt;data trend;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input tag $ @@;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp; tr-c tr-c tr-c tr-c tr-c tr-tr tr tr&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;This can be implemented using retain statement and lag function, but I think there should be some smarter way to implement it.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2012 19:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-best-way-to-implement-this-logic/m-p/122456#M25122</guid>
      <dc:creator>Fisher</dc:creator>
      <dc:date>2012-11-09T19:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to implement this logic?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-best-way-to-implement-this-logic/m-p/122457#M25123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data trend;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input tag $ @@;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length _tag $8;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain _tag ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _tag=coalescec(tag,_tag);&lt;/P&gt;&lt;P&gt;&amp;nbsp; if missing(tag) then tag=ifc(_tag='tr-tr','tr',_tag);&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop _tag;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;&amp;nbsp; tr-c . . . tr-c tr-tr . .&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2012 19:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-best-way-to-implement-this-logic/m-p/122457#M25123</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-09T19:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to implement this logic?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-best-way-to-implement-this-logic/m-p/122458#M25124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Excellent! I never tried this function, always learn something from SAS gurus here.&lt;/P&gt;&lt;P&gt;Thanks Hai.kuo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Nov 2012 20:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-best-way-to-implement-this-logic/m-p/122458#M25124</guid>
      <dc:creator>Fisher</dc:creator>
      <dc:date>2012-11-09T20:10:24Z</dc:date>
    </item>
  </channel>
</rss>

