<?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/372602#M89113</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;Thanks, Art.&lt;/P&gt;</description>
    <pubDate>Sun, 02 Jul 2017 18:30:04 GMT</pubDate>
    <dc:creator>SAS_inquisitive</dc:creator>
    <dc:date>2017-07-02T18:30:04Z</dc:date>
    <item>
      <title>retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain/m-p/372597#M89109</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This example code is takne from this paper (&lt;A href="https://www.pharmasug.org/proceedings/2013/TF/PharmaSUG-2013-TF12.pdf" target="_blank"&gt;https://www.pharmasug.org/proceedings/2013/TF/PharmaSUG-2013-TF12.pdf&lt;/A&gt;). I don' think we need to retain ldosdt variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA ds1a (keep=usubjid fdosdt ldosdt);
	set ipadmin;
	by usubjid startdt;
	retain fdosdt ldosdt;

	if first.usubjid then
		fdosdt = startdt;

	if last.usubjid then
		do;
			ldosdt = startdt;
			output;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried to simulate the above with this program.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	input id $ x;
	cards;
a  1
a  2
a  3
;
run;

data want;
	set test;
	by id;
	retain f_;

	if first.id then
		f_=x;

	if last.id then
		do;
			l_=x;
			output;
		end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 18:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain/m-p/372597#M89109</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2017-07-02T18:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain/m-p/372600#M89111</link>
      <description>&lt;P&gt;You are correct .. you don't have to retain the 2nd variable. Doesn't hurt, but definitely not necessary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 18:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain/m-p/372600#M89111</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-02T18:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: retain</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain/m-p/372602#M89113</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;&amp;nbsp;Thanks, Art.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2017 18:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain/m-p/372602#M89113</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2017-07-02T18:30:04Z</dc:date>
    </item>
  </channel>
</rss>

