<?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 using Array and Retain in Data Step... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73687#M15865</link>
    <description>Thanks Milton, appreciate your help. &lt;BR /&gt;
&lt;BR /&gt;
Unfortunately I do not have the result Table to match with.</description>
    <pubDate>Tue, 06 Apr 2010 17:00:48 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-04-06T17:00:48Z</dc:date>
    <item>
      <title>Question about using Array and Retain in Data Step...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73685#M15863</link>
      <description>I will appreciate if someone can explain what the following code is doing. I do not have a way to debug this. &lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance. &lt;BR /&gt;
&lt;BR /&gt;
Code:&lt;BR /&gt;
&lt;BR /&gt;
data bk_baddata2 (KEEP = loan_id newbaddata4 newbaddata6 newbaddata7);&lt;BR /&gt;
                set bk_baddata;&lt;BR /&gt;
                                array bad(*) baddata4 baddata6 baddata7;&lt;BR /&gt;
                                array new(*) newbaddata4 newbaddata6 newbaddata7;&lt;BR /&gt;
                                retain newbaddata4 newbaddata6 newbaddata7;&lt;BR /&gt;
                                by loan_id;&lt;BR /&gt;
                if first.loan_id then &lt;BR /&gt;
                                                do;&lt;BR /&gt;
                                                                newbaddata4 = .;&lt;BR /&gt;
                                                                newbaddata6 = .;&lt;BR /&gt;
                                                                newbaddata7 = .;&lt;BR /&gt;
                                                end;&lt;BR /&gt;
                do i = 1 to 3;&lt;BR /&gt;
                                if bad(i) NE . then new(i) = bad(i);&lt;BR /&gt;
                end;&lt;BR /&gt;
                if last.loan_id;&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 06 Apr 2010 16:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73685#M15863</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-06T16:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Question about using Array and Retain in Data Step...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73686#M15864</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
the code actually sets the value of the baddata columns equal to the newbaddata columns if the baddata does not have a null value. then the last record per loan_id is only written into the dataset bk_baddata2 along with the loan_id and newbaddata columns.&lt;BR /&gt;
&lt;BR /&gt;
regarding the use of retain, i'm not quite sure but i think the retain part and the if first.loan_id part is redundant. no default values were set in the retain statement so the default value will be missing. i'm not sure if both are really needed. &lt;BR /&gt;
&lt;BR /&gt;
by any chance do you know what the result table should look like?&lt;BR /&gt;
&lt;BR /&gt;
hope this helps. if ever i explained something wrong please do correct it. thanks!&lt;BR /&gt;
&lt;BR /&gt;
Milton</description>
      <pubDate>Tue, 06 Apr 2010 16:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73686#M15864</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2010-04-06T16:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Question about using Array and Retain in Data Step...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73687#M15865</link>
      <description>Thanks Milton, appreciate your help. &lt;BR /&gt;
&lt;BR /&gt;
Unfortunately I do not have the result Table to match with.</description>
      <pubDate>Tue, 06 Apr 2010 17:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73687#M15865</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-06T17:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: Question about using Array and Retain in Data Step...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73688#M15866</link>
      <description>One question still remains, do the following three blocks execute for every observation ?&lt;BR /&gt;
&lt;BR /&gt;
Specially, the #2 DO loop. Does it execute for each observation?&lt;BR /&gt;
&lt;BR /&gt;
(1) if first.loan_id then&lt;BR /&gt;
do;&lt;BR /&gt;
newbaddata4 = .;&lt;BR /&gt;
newbaddata6 = .;&lt;BR /&gt;
newbaddata7 = .;&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
(2) do i = 1 to 3;&lt;BR /&gt;
if bad(i) NE . then new(i) = bad(i);&lt;BR /&gt;
end;&lt;BR /&gt;
&lt;BR /&gt;
(3) if last.loan_id;</description>
      <pubDate>Tue, 06 Apr 2010 17:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73688#M15866</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-04-06T17:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: Question about using Array and Retain in Data Step...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73689#M15867</link>
      <description>It all depends on your input data - if you only have one obs per LOAN_ID, the answer is yes, otherwise #1 and #3 is NO, #2 is NO (it executes 3 times per observations, given your DO &lt;EXPRESSION&gt; criteria.&lt;BR /&gt;
&lt;BR /&gt;
And, why would you be asking the questions (other than a homework/quiz assignment), if you actually don't have any data to work through the discovery process with your own SAS system, input data, combined with some PUTLOG _ALL_; commands?&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;/EXPRESSION&gt;</description>
      <pubDate>Tue, 06 Apr 2010 17:27:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Question-about-using-Array-and-Retain-in-Data-Step/m-p/73689#M15867</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-04-06T17:27:30Z</dc:date>
    </item>
  </channel>
</rss>

