<?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: Can someone try it arrays? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/411961#M100720</link>
    <description>&lt;P&gt;Try not to overwrite your input.&lt;/P&gt;
&lt;P&gt;You need two arrays one for the input counts and another for the generated strings.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have;
  array col(5);
  array result(5) $20 ;
  if not missing(col99) then do i=1 to 5 ;
    if missing(col(i)) then result(i)=' ';
    else result(i)=put(col(i),3.)||' ('||put((col(i)/col99)*100,5.1)||')';
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Nov 2017 15:17:56 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-11-09T15:17:56Z</dc:date>
    <item>
      <title>Can someone try it arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/411946#M100712</link>
      <description>&lt;P&gt;data have;&lt;BR /&gt;input col1 col2 col3 col4 col5 col99;&lt;BR /&gt;cards;&lt;BR /&gt;1 2 3 4 5 21&lt;BR /&gt;4 1 5 3 1 20&lt;BR /&gt;1 5 3 2 4 22&lt;BR /&gt;1 4 2 3 1 15&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data have;&lt;BR /&gt;set have;&lt;BR /&gt;if ~missing(col1) and ~missing(col99) then col11=put(col1,3.)||' ('||put((col1/col99)*100,5.1)||')';&lt;BR /&gt;if ~missing(col2) and ~missing(col99) then col21=put(col2,3.)||' ('||put((col2/col99)*100,5.1)||')';&lt;BR /&gt;if ~missing(col3) and ~missing(col99) then col31=put(col3,3.)||' ('||put((col3/col99)*100,5.1)||')';&lt;BR /&gt;if ~missing(col4) and ~missing(col99) then col41=put(col4,3.)||' ('||put((col4/col99)*100,5.1)||')';&lt;BR /&gt;if ~missing(col5) and ~missing(col99) then col51=put(col5,3.)||' ('||put((col5/col99)*100,5.1)||')';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone try it arrays Please I'm written in data steps&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 14:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/411946#M100712</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2017-11-09T14:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone try it arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/411950#M100715</link>
      <description>&lt;P&gt;Avoid using ~, not sure that even works.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
  input col1 col2 col3 col4 col5 col99;
cards;
1 2 3 4 5 21
4 1 5 3 1 20
1 5 3 2 4 22
1 4 2 3 1 15
run;

data want;
  set have;
  array v{6} col1--col99;
  array res{6} $50;
  do i=1 to 5;
    if not missing(v{i}) and not missing(v{6}) then res{i}=cat(put(v{i},3.),' (',put((v{i}/v{6})*100,5.1),')');
  end;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 14:49:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/411950#M100715</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-09T14:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone try it arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/411952#M100716</link>
      <description>&lt;P&gt;Regardless of the final approach, I would suggest cutting down the number of comparisons.&amp;nbsp; Using your original code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if not missing(col99) then do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if ~missing(col1) then col11=put(col1,3.)||' ('||put((col1/col99)*100,5.1)||')';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if ~missing(col2) then col21=put(col2,3.)||' ('||put((col2/col99)*100,5.1)||')';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if ~missing(col3) then col31=put(col3,3.)||' ('||put((col3/col99)*100,5.1)||')';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if ~missing(col4) then col41=put(col4,3.)||' ('||put((col4/col99)*100,5.1)||')';&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if ~missing(col5) then col51=put(col5,3.)||' ('||put((col5/col99)*100,5.1)||')';&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That suggestion could easily be applied to an array-based solution, such as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if not missing(col99) then do j=1 to 5;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 14:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/411952#M100716</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-11-09T14:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone try it arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/411961#M100720</link>
      <description>&lt;P&gt;Try not to overwrite your input.&lt;/P&gt;
&lt;P&gt;You need two arrays one for the input counts and another for the generated strings.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have;
  array col(5);
  array result(5) $20 ;
  if not missing(col99) then do i=1 to 5 ;
    if missing(col(i)) then result(i)=' ';
    else result(i)=put(col(i),3.)||' ('||put((col(i)/col99)*100,5.1)||')';
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 15:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/411961#M100720</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-11-09T15:17:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone try it arrays?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/412225#M100820</link>
      <description>Thanks Everyone for your support...</description>
      <pubDate>Fri, 10 Nov 2017 06:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-try-it-arrays/m-p/412225#M100820</guid>
      <dc:creator>rajeshalwayswel</dc:creator>
      <dc:date>2017-11-10T06:24:52Z</dc:date>
    </item>
  </channel>
</rss>

