<?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 A retain problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/A-retain-problem/m-p/137749#M295977</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please help me debug this code. This code is supposed to retain the last nonmissing element of a field.&lt;/P&gt;&lt;P&gt;Some of the values in one array element are carried over to the next array element eg: Gender is carried to Country so that you see F in the Country field;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data kplast;&lt;/P&gt;&lt;P&gt;set lapazsrt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array test $ _character_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;by Medical_Record_Number Date_Created;&lt;/P&gt;&lt;P&gt;length temp $50.;&lt;/P&gt;&lt;P&gt;do i=1 to dim(test);&lt;/P&gt;&lt;P&gt;retain temp "";&lt;/P&gt;&lt;P&gt;if&amp;nbsp; first.Medical_Record_Number then temp="";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if missing(test(i)) then &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; test(i)=strip(input(temp,$50.));&lt;/P&gt;&lt;P&gt;&amp;nbsp; else temp=strip(input(test(i),$50.));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.Medical_Record_Number ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Jul 2014 18:33:12 GMT</pubDate>
    <dc:creator>lyton80</dc:creator>
    <dc:date>2014-07-25T18:33:12Z</dc:date>
    <item>
      <title>A retain problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-retain-problem/m-p/137749#M295977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please help me debug this code. This code is supposed to retain the last nonmissing element of a field.&lt;/P&gt;&lt;P&gt;Some of the values in one array element are carried over to the next array element eg: Gender is carried to Country so that you see F in the Country field;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data kplast;&lt;/P&gt;&lt;P&gt;set lapazsrt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array test $ _character_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;by Medical_Record_Number Date_Created;&lt;/P&gt;&lt;P&gt;length temp $50.;&lt;/P&gt;&lt;P&gt;do i=1 to dim(test);&lt;/P&gt;&lt;P&gt;retain temp "";&lt;/P&gt;&lt;P&gt;if&amp;nbsp; first.Medical_Record_Number then temp="";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if missing(test(i)) then &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; test(i)=strip(input(temp,$50.));&lt;/P&gt;&lt;P&gt;&amp;nbsp; else temp=strip(input(test(i),$50.));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last.Medical_Record_Number ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jul 2014 18:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-retain-problem/m-p/137749#M295977</guid>
      <dc:creator>lyton80</dc:creator>
      <dc:date>2014-07-25T18:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: A retain problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/A-retain-problem/m-p/137750#M295978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Heres what your code is doing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Check first element of array, if missing then set to blank (which is missing for character )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if second element isn't missing it assigns that value to temp. which is kept until reset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If the third element of the array is missing then it assigns the value of the second element to the third element as that is what is in temp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It may be helpful to post a few records of input and the expected output. I also suspect the location of the the do loop may be an issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jul 2014 19:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/A-retain-problem/m-p/137750#M295978</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-07-25T19:36:38Z</dc:date>
    </item>
  </channel>
</rss>

