<?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: Retain in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423850#M104268</link>
    <description>&lt;P&gt;Or since you desire traditional retain statement method, here you go:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by id;&lt;BR /&gt;retain _t;&lt;BR /&gt;if first.id then n=0;&lt;BR /&gt;n+1;&lt;BR /&gt;if n=2 then _t=xyz;&lt;BR /&gt;else if n=4 then xyz=_t;&lt;BR /&gt;drop n _t;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Dec 2017 06:08:51 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2017-12-28T06:08:51Z</dc:date>
    <item>
      <title>Retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423847#M104265</link>
      <description>Hi&lt;BR /&gt;Recently I started learning SAS , I need help with retain statement&lt;BR /&gt;I have the following dataset&lt;BR /&gt;&lt;BR /&gt;Id xyz&lt;BR /&gt;A 1&lt;BR /&gt;A 2&lt;BR /&gt;A 3&lt;BR /&gt;A 4&lt;BR /&gt;B 1&lt;BR /&gt;B 2&lt;BR /&gt;B 3&lt;BR /&gt;B 4&lt;BR /&gt;&lt;BR /&gt;I want to retain second observation in each group and reassign its value in 4th observation ..like&lt;BR /&gt;&lt;BR /&gt;Id xyz&lt;BR /&gt;A 1&lt;BR /&gt;A 2&lt;BR /&gt;A 3&lt;BR /&gt;A 2&lt;BR /&gt;B 1&lt;BR /&gt;B 2&lt;BR /&gt;B 3&lt;BR /&gt;B 2&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Thu, 28 Dec 2017 05:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423847#M104265</guid>
      <dc:creator>Sama1</dc:creator>
      <dc:date>2017-12-28T05:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423848#M104266</link>
      <description />
      <pubDate>Thu, 28 Dec 2017 05:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423848#M104266</guid>
      <dc:creator>Sama1</dc:creator>
      <dc:date>2017-12-28T05:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423849#M104267</link>
      <description>&lt;P&gt;A nice home work &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input Id $ xyz;&lt;BR /&gt;datalines;&lt;BR /&gt;A 1&lt;BR /&gt;A 2&lt;BR /&gt;A 3&lt;BR /&gt;A 4&lt;BR /&gt;B 1&lt;BR /&gt;B 2&lt;BR /&gt;B 3&lt;BR /&gt;B 4&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;do _n_=1 by 1 until(last.id);&lt;BR /&gt;set have;&lt;BR /&gt;by id;&lt;BR /&gt;if _n_=2 then _t=xyz;&lt;BR /&gt;else if _n_=4 then xyz=_t;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;drop _:;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 06:05:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423849#M104267</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-12-28T06:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: Retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423850#M104268</link>
      <description>&lt;P&gt;Or since you desire traditional retain statement method, here you go:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by id;&lt;BR /&gt;retain _t;&lt;BR /&gt;if first.id then n=0;&lt;BR /&gt;n+1;&lt;BR /&gt;if n=2 then _t=xyz;&lt;BR /&gt;else if n=4 then xyz=_t;&lt;BR /&gt;drop n _t;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 06:08:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423850#M104268</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-12-28T06:08:51Z</dc:date>
    </item>
    <item>
      <title>Re: Retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423851#M104269</link>
      <description>Thank you very much &lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;☺️</description>
      <pubDate>Thu, 28 Dec 2017 06:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423851#M104269</guid>
      <dc:creator>Sama1</dc:creator>
      <dc:date>2017-12-28T06:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423949#M104317</link>
      <description>&lt;P&gt;Please mark the appropriate response (not this one)&amp;nbsp;as the correct answer so that we know your question is resolved.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 19:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain/m-p/423949#M104317</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-28T19:16:31Z</dc:date>
    </item>
  </channel>
</rss>

