<?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 Data rule for horizontal records? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-rule-for-horizontal-records/m-p/293152#M60938</link>
    <description>&lt;P&gt;/*&lt;/P&gt;&lt;P&gt;Hi SAS Forum,&lt;/P&gt;&lt;P&gt;I have the below SAS data set which has 6 accts.&lt;BR /&gt;It shows all six accts start in January with status = 7 which means customer is deceased.&lt;/P&gt;&lt;P&gt;Then it shows how each deceased acct ages.&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input acct_num Jan_status Feb_status Mar_status Apr_status May_status Jun_status;&lt;BR /&gt;cards;&lt;BR /&gt;111 7 . 11 525 7 11&lt;BR /&gt;222 7 7 7 7 11 .&lt;BR /&gt;333 7 800 11 11 11 1&lt;BR /&gt;444 7 7 11 . . .&lt;BR /&gt;555 7 . . . . 1&lt;BR /&gt;666 7 . . . . .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Question:&lt;/P&gt;&lt;P&gt;Among the 6 accts, acct 111 and 555 are having data quality problems. Why? becasue the deceased acct&lt;BR /&gt;disappear at least in a single middle month and then re-appear. These two accts are therefore problem accts.&lt;BR /&gt;My question is how to do the coding to flag these 2 accts as problem accts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Acct number 222 have no problem because it disappears sometime of its age but never re-aapears.&lt;BR /&gt;- Acct number 333 have no problem because it never disappears during its age.&lt;BR /&gt;- Acct number 444 have no problem because it disappears sometime of its age but never re-aapears.&lt;BR /&gt;-Acct number 666 have no problem because it disappears sometime of its age but never re-aapears.&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;/*My attempt is below but it doesn't give correct resutls. Could some expert help me.*/&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;if Feb_status = . and Mar_status ^= . then flag = 'problem';&lt;BR /&gt;else if Mar_status = . and Apr_status ^= . then flag = 'problem';&lt;BR /&gt;else if Apr_status = . and May_status ^= . then flag = 'problem';&lt;BR /&gt;else if May_status = . and jun_status ^= . then flag = 'problem';&lt;BR /&gt;else flag = 'no prob';&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Mirisa&lt;/P&gt;</description>
    <pubDate>Mon, 22 Aug 2016 14:30:12 GMT</pubDate>
    <dc:creator>dunga</dc:creator>
    <dc:date>2016-08-22T14:30:12Z</dc:date>
    <item>
      <title>Data rule for horizontal records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-rule-for-horizontal-records/m-p/293152#M60938</link>
      <description>&lt;P&gt;/*&lt;/P&gt;&lt;P&gt;Hi SAS Forum,&lt;/P&gt;&lt;P&gt;I have the below SAS data set which has 6 accts.&lt;BR /&gt;It shows all six accts start in January with status = 7 which means customer is deceased.&lt;/P&gt;&lt;P&gt;Then it shows how each deceased acct ages.&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input acct_num Jan_status Feb_status Mar_status Apr_status May_status Jun_status;&lt;BR /&gt;cards;&lt;BR /&gt;111 7 . 11 525 7 11&lt;BR /&gt;222 7 7 7 7 11 .&lt;BR /&gt;333 7 800 11 11 11 1&lt;BR /&gt;444 7 7 11 . . .&lt;BR /&gt;555 7 . . . . 1&lt;BR /&gt;666 7 . . . . .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Question:&lt;/P&gt;&lt;P&gt;Among the 6 accts, acct 111 and 555 are having data quality problems. Why? becasue the deceased acct&lt;BR /&gt;disappear at least in a single middle month and then re-appear. These two accts are therefore problem accts.&lt;BR /&gt;My question is how to do the coding to flag these 2 accts as problem accts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Acct number 222 have no problem because it disappears sometime of its age but never re-aapears.&lt;BR /&gt;- Acct number 333 have no problem because it never disappears during its age.&lt;BR /&gt;- Acct number 444 have no problem because it disappears sometime of its age but never re-aapears.&lt;BR /&gt;-Acct number 666 have no problem because it disappears sometime of its age but never re-aapears.&lt;/P&gt;&lt;P&gt;*/&lt;/P&gt;&lt;P&gt;/*My attempt is below but it doesn't give correct resutls. Could some expert help me.*/&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;if Feb_status = . and Mar_status ^= . then flag = 'problem';&lt;BR /&gt;else if Mar_status = . and Apr_status ^= . then flag = 'problem';&lt;BR /&gt;else if Apr_status = . and May_status ^= . then flag = 'problem';&lt;BR /&gt;else if May_status = . and jun_status ^= . then flag = 'problem';&lt;BR /&gt;else flag = 'no prob';&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Mirisa&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 14:30:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-rule-for-horizontal-records/m-p/293152#M60938</guid>
      <dc:creator>dunga</dc:creator>
      <dc:date>2016-08-22T14:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Data rule for horizontal records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-rule-for-horizontal-records/m-p/293154#M60939</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;data have;
input acct_num Jan_status Feb_status Mar_status Apr_status May_status Jun_status;
cards;
111 7 . 11 525 7 11
222 7 7 7 7 11 .
333 7 800 11 11 11 1
444 7 7 11 . . .
555 7 . . . . 1
666 7 . . . . .
;
run;

data want (drop=miss);
  set have;
  array vals{6} jan_status feb_status mar_status apr_status may_status jun_status;
  miss=0;
  do i=1 to 6;
    if vals{i}=. then miss=1;
    else if miss=1 and vals{i} ne . then flag="Y";
  end;
run;&lt;/PRE&gt;
&lt;P&gt;You could shrink the code somewhat, but that shows the process. &amp;nbsp;I would also ask why you are making it hard for yourself? &amp;nbsp;Not only are you working with transposed data (would be far better having a month column and the data goes down the page - would make your coding far simpler), but you have prefixed each variable with a different text string so you can't even use generic names. &amp;nbsp;If you have labelled them status_&amp;lt;mon&amp;gt; then you could use status: to mean all of them.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 14:40:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-rule-for-horizontal-records/m-p/293154#M60939</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-22T14:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: Data rule for horizontal records?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-rule-for-horizontal-records/m-p/293192#M60952</link>
      <description>&lt;P&gt;Hi RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code is great. It worked like anything.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mirisa&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2016 17:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-rule-for-horizontal-records/m-p/293192#M60952</guid>
      <dc:creator>dunga</dc:creator>
      <dc:date>2016-08-22T17:11:20Z</dc:date>
    </item>
  </channel>
</rss>

