<?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: Question about RETAIN statement. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434460#M107815</link>
    <description>&lt;P&gt;Photographs of your data is going to be really hard for someone to use in testing solutions for you.&lt;/P&gt;
&lt;P&gt;What was your input data?&lt;BR /&gt;What is the output your want for that input data?&lt;/P&gt;
&lt;P&gt;One thing to check if that the variable you are trying to "retain" is not already on the input dataset. Because if it is the SET statement will overwrite the value you are trying to "retain".&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2018 05:23:03 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2018-02-06T05:23:03Z</dc:date>
    <item>
      <title>Question about RETAIN statement.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434443#M107808</link>
      <description>&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;data se;&lt;BR /&gt;retain sestdtc seendtc;
 set exr;
 by usubjid etcd element dtc;
 if first.element then sestdtc = dtc;
 if last.element then seendtc = dtc;
  if last.element;

 run;&lt;/PRE&gt;&lt;P&gt;The above code not working.I need to keep seendtc same as sestdtc for next etcd as shown on right side of image.Any suggestions please?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txt.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18347iB70FA3B03356F630/image-size/large?v=v2&amp;amp;px=999" role="button" title="txt.png" alt="txt.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 01:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434443#M107808</guid>
      <dc:creator>paddyb</dc:creator>
      <dc:date>2018-02-06T01:55:18Z</dc:date>
    </item>
    <item>
      <title>Question about RETAIN statement.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434442#M107809</link>
      <description>&lt;PRE&gt;data se;

retain sestdtc seendtc;
 set exr;
 by usubjid etcd element dtc;
 if first.element then sestdtc = dtc;
 if last.element then seendtc = dtc;
  if last.element;

 run;&lt;/PRE&gt;&lt;P&gt;The above code not working.I need to keep seendtc same as sestdtc for next etcd as shown on right side of image.Any suggestions please?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txt.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18347iB70FA3B03356F630/image-size/large?v=v2&amp;amp;px=999" role="button" title="txt.png" alt="txt.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txt.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18348i8155F67C96E66A04/image-size/large?v=v2&amp;amp;px=999" role="button" title="txt.png" alt="txt.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 01:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434442#M107809</guid>
      <dc:creator>paddyb</dc:creator>
      <dc:date>2018-02-06T01:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Question about RETAIN statement.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434445#M107810</link>
      <description>&lt;P&gt;Your program refers to variables that don't exist, such as ELEMENT and DTC.&amp;nbsp; Well, maybe they exist but we have no idea what is in them.&amp;nbsp; So let's take the results in the data set SE and fix them according to what you say that you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set se;&lt;/P&gt;
&lt;P&gt;by usubjid;&lt;/P&gt;
&lt;P&gt;prior_val = lag(seendtc);&lt;/P&gt;
&lt;P&gt;if first.usubjid=0 then sestdtc = prior_val;&lt;/P&gt;
&lt;P&gt;drop prior_val;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 02:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434445#M107810</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-06T02:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Question about RETAIN statement.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434450#M107812</link>
      <description>&lt;P&gt;please give your want and output in form of datastep, that will be make bit easy for someone who wants to help you. you have just showed one scenario, it would be better, if you can show more than one scenario.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 02:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434450#M107812</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-02-06T02:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Question about RETAIN statement.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434451#M107813</link>
      <description>&lt;P&gt;FIRST/LAST/RETAIN don't work in this situation because you're crossing variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead try the LAG() function to capture the previous value. You can use FIRST/LAST to reset the values as needed, but you didn't post enough data for that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try and make your images bigger in the future so they're easily legible, they're barely legible at this point.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-02-05 at 7.16.02 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18350i59B8F95DD1FCFC8B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-02-05 at 7.16.02 PM.png" alt="Screen Shot 2018-02-05 at 7.16.02 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 02:16:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434451#M107813</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-02-06T02:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Question about RETAIN statement.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434459#M107814</link>
      <description>&lt;P&gt;Thanks ,It worked&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 05:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434459#M107814</guid>
      <dc:creator>paddyb</dc:creator>
      <dc:date>2018-02-06T05:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Question about RETAIN statement.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434460#M107815</link>
      <description>&lt;P&gt;Photographs of your data is going to be really hard for someone to use in testing solutions for you.&lt;/P&gt;
&lt;P&gt;What was your input data?&lt;BR /&gt;What is the output your want for that input data?&lt;/P&gt;
&lt;P&gt;One thing to check if that the variable you are trying to "retain" is not already on the input dataset. Because if it is the SET statement will overwrite the value you are trying to "retain".&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 05:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434460#M107815</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-02-06T05:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Question about RETAIN statement.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434461#M107816</link>
      <description>&lt;P&gt;sorry ,it was not actual dataset. I created dummy to ask query ,Actually I wanted to retain value of seendtc and assign as seendtc for next element.Thanks for looking into it.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 05:35:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-RETAIN-statement/m-p/434461#M107816</guid>
      <dc:creator>paddyb</dc:creator>
      <dc:date>2018-02-06T05:35:26Z</dc:date>
    </item>
  </channel>
</rss>

