<?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, first.to in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864470#M341395</link>
    <description>if you could provide a sample dataset, that would help a lot</description>
    <pubDate>Thu, 16 Mar 2023 07:55:58 GMT</pubDate>
    <dc:creator>sbxjld3</dc:creator>
    <dc:date>2023-03-16T07:55:58Z</dc:date>
    <item>
      <title>retain, first.to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864463#M341391</link>
      <description>&lt;PRE&gt;data exchange;
set exchange;
retain _from;
by from to;
if first.to then valid_to=.;
else valid_to = _from-1;
output;
_from=valid_from;
where to='HKD';
format _from valid_to date9.;
run;
&lt;/PRE&gt;
&lt;P&gt;what does it mean by retain _from by from to? in exchange dataset, there is only 'from','to','valid_from' and 'exchg_rate', 4 columns.. where does _from come from?&lt;/P&gt;
&lt;P&gt;very strange the above code...&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 07:01:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864463#M341391</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2023-03-16T07:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: retain, first.to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864464#M341392</link>
      <description>&lt;P&gt;First, Maxim 1: Read the Documentation (to understand what the statements do)&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0yeyftk8ftuckn1o5qzy53284gz.htm" target="_blank" rel="noopener"&gt;BY Statement&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0t2ac0tfzcgbjn112mu96hkgg9o.htm" target="_blank" rel="noopener"&gt;RETAIN Statement&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, Maxim 3. Know Your Data&lt;/P&gt;
&lt;P&gt;Inspect your datasets to see which variables are contained&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variables not contained in the incoming dataset(s), but used in the code, will automatically be created by the data step compiler.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 07:19:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864464#M341392</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-16T07:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: retain, first.to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864466#M341393</link>
      <description>&lt;P&gt;RETAIN means _from will keep its value between iterations of the data step.&lt;/P&gt;
&lt;P&gt;_from and valid_to are created in this data step.&lt;/P&gt;
&lt;P&gt;BY means that the data step expects the input data to be sorted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Strange, no idea since this step is clearly taken out of the context where it executes.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 07:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864466#M341393</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2023-03-16T07:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: retain, first.to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864468#M341394</link>
      <description>&lt;P&gt;The placement of the BY statement does not matter that much, it just pertains to the previous SET or MERGE statement.&lt;/P&gt;
&lt;P&gt;Your code is equivalent to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data exchange;
set exchange;
by from to;
retain _from;
if first.to then valid_to=.;
else valid_to = _from-1;
output;
_from=valid_from;
where to='HKD';
format _from valid_to date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which is obviously a lot easier to read.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 07:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864468#M341394</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-03-16T07:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: retain, first.to</title>
      <link>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864470#M341395</link>
      <description>if you could provide a sample dataset, that would help a lot</description>
      <pubDate>Thu, 16 Mar 2023 07:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/retain-first-to/m-p/864470#M341395</guid>
      <dc:creator>sbxjld3</dc:creator>
      <dc:date>2023-03-16T07:55:58Z</dc:date>
    </item>
  </channel>
</rss>

