<?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: Help in finding the New Rx Writers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428197#M105692</link>
    <description>&lt;P&gt;Loop through the array from reverse to find the first non-zero?&lt;/P&gt;
&lt;P&gt;untested&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

array rx(5);
array nw(5);

dp i=1 to 5;
nw(i)=0;
end;

do i=5 to 1 by -1
if rx(i) ne 0 then do;
nw(i) = 1;
leave;
end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
    <pubDate>Tue, 16 Jan 2018 22:21:01 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-01-16T22:21:01Z</dc:date>
    <item>
      <title>Help in finding the New Rx Writers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428194#M105690</link>
      <description>&lt;P&gt;I have the following sample data for 5 weeks by doctor_ID&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;/P&gt;
&lt;P&gt;input id rx1-rx5;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;12 1 0 4 0 3&lt;/P&gt;
&lt;P&gt;13 0 2 0 0 0&lt;/P&gt;
&lt;P&gt;14 0 0 3 1 0&lt;/P&gt;
&lt;P&gt;15 2 1 0 0 2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get the new writers each week. rx1-rx5 is the Rxs the doctors wrote for 1 thru 5 weeks. Rx1 being the latest week. Rx5 is oldest week.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Output should be as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID nw1 nw2 nw3 nw4 nw5&lt;/P&gt;
&lt;P&gt;12&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;13&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;14&amp;nbsp; &amp;nbsp; 0&amp;nbsp;&amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;
&lt;P&gt;15&amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp;0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would appreciate any help in this&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 22:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428194#M105690</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2018-01-16T22:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help in finding the New Rx Writers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428196#M105691</link>
      <description>&lt;P&gt;Whats the logic/rules to get from rx to nw?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 22:18:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428196#M105691</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-16T22:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help in finding the New Rx Writers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428197#M105692</link>
      <description>&lt;P&gt;Loop through the array from reverse to find the first non-zero?&lt;/P&gt;
&lt;P&gt;untested&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

array rx(5);
array nw(5);

dp i=1 to 5;
nw(i)=0;
end;

do i=5 to 1 by -1
if rx(i) ne 0 then do;
nw(i) = 1;
leave;
end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 16 Jan 2018 22:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428197#M105692</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-16T22:21:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help in finding the New Rx Writers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428209#M105697</link>
      <description>&lt;P&gt;Thanks Reeza for the help. It worked..&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2018 22:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428209#M105697</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2018-01-16T22:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help in finding the New Rx Writers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428214#M105698</link>
      <description>&lt;P&gt;two loops can be avoided:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id rx1-rx5;
cards;
12 1 0 4 0 3
13 0 2 0 0 0
14 0 0 3 1 0
15 2 1 0 0 2
;

data want;
set have;
array t(*) rx:;
array nw(5);
do _n_=5 by -1 to 1;
nw(_n_)=0;
if flag then nw(_n_)=0;
else if t(_n_) ne 0 then do;nw(_n_)=1;flag=1;continue;end;
end;
drop flag;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jan 2018 23:19:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428214#M105698</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-16T23:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Help in finding the New Rx Writers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428458#M105787</link>
      <description>&lt;P&gt;I am trying to use the&amp;nbsp;above&amp;nbsp;&amp;nbsp;code in macro as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro test;&lt;BR /&gt; data testdata;&lt;BR /&gt; set lib.testdata;&lt;BR /&gt; &lt;BR /&gt; array trx(106) trx1-trx106;&lt;BR /&gt; array nw(106) nw1- nw106;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; %do i=1 %to 106;&lt;BR /&gt; nw(&amp;amp;i)=0;&lt;BR /&gt; %end;&lt;BR /&gt; &lt;BR /&gt; %do i=106 %to 1 by -1;&lt;BR /&gt; %if trx(&amp;amp;i) ne 0 %then %do;&lt;BR /&gt; nw(&amp;amp;i) = 1;&lt;BR /&gt; leave;&lt;BR /&gt; %end;&lt;BR /&gt; %end; &lt;BR /&gt; run;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;%test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get the following error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric&lt;BR /&gt; operand is required. The condition was: 1 by -1&lt;BR /&gt;ERROR: The %TO value of the %DO I loop is invalid.&lt;BR /&gt;ERROR: The macro TEST will stop executing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would appreciate any help in this..&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 16:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428458#M105787</guid>
      <dc:creator>pp2014</dc:creator>
      <dc:date>2018-01-17T16:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: Help in finding the New Rx Writers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428462#M105788</link>
      <description>&lt;P&gt;Don't write a macro loop, it doesn't add anything here at all, make it a regular DO loop.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11613"&gt;@pp2014&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to use the&amp;nbsp;above&amp;nbsp;&amp;nbsp;code in macro as follows:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro test;&lt;BR /&gt; data testdata;&lt;BR /&gt; set lib.testdata;&lt;BR /&gt; &lt;BR /&gt; array trx(106) trx1-trx106;&lt;BR /&gt; array nw(106) nw1- nw106;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; %do i=1 %to 106;&lt;BR /&gt; nw(&amp;amp;i)=0;&lt;BR /&gt; %end;&lt;BR /&gt; &lt;BR /&gt; %do i=106 %to 1 by -1;&lt;BR /&gt; %if trx(&amp;amp;i) ne 0 %then %do;&lt;BR /&gt; nw(&amp;amp;i) = 1;&lt;BR /&gt; leave;&lt;BR /&gt; %end;&lt;BR /&gt; %end; &lt;BR /&gt; run;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;%test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get the following error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric&lt;BR /&gt; operand is required. The condition was: 1 by -1&lt;BR /&gt;ERROR: The %TO value of the %DO I loop is invalid.&lt;BR /&gt;ERROR: The macro TEST will stop executing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would appreciate any help in this..&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2018 16:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-finding-the-New-Rx-Writers/m-p/428462#M105788</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-17T16:16:04Z</dc:date>
    </item>
  </channel>
</rss>

