<?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 help with arrays! in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/help-with-arrays/m-p/68257#M19548</link>
    <description>Hi guys.&lt;BR /&gt;
&lt;BR /&gt;
I have two data sets that looks like this:&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
input month monthly_sum sum1 sum2 sum3 sum4 sum5;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 10 1 1 1 1 1 &lt;BR /&gt;
2 20 2 2 2 2 .&lt;BR /&gt;
3 30 3 3 3 . .&lt;BR /&gt;
4 40 4 4 . . . &lt;BR /&gt;
5 50 5 . . . .&lt;BR /&gt;
6 60 . . . . . &lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data b;&lt;BR /&gt;
input month monthly_sum total1 total2 total3 total4 total5;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 100 10 10 10 10 10 &lt;BR /&gt;
2 200 20 20 20 20 .&lt;BR /&gt;
3 300 30 30 30 . .&lt;BR /&gt;
4 400 40 40 . . . &lt;BR /&gt;
5 500 50 . . . .&lt;BR /&gt;
6 600 . . . . . &lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
What I want to do is create a new dataset that divides all the cells for sum1-sum5 for every row from dataset a with the "same location" cells for total1-total5 from dataset b.&lt;BR /&gt;
&lt;BR /&gt;
The result should look like this:&lt;BR /&gt;
data result;&lt;BR /&gt;
input month monthly_sum calc1 calc2 calc3 calc4 calc5;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 10 0.1 0.1 0.1 0.1 0.1 &lt;BR /&gt;
2 20 0.1 0.1 0.1 0.1 .&lt;BR /&gt;
3 30 0.1 0.1 0.1 . .&lt;BR /&gt;
4 40 0.1 0.1 . . . &lt;BR /&gt;
5 50 0.1 . . . .&lt;BR /&gt;
6 60 . . . . . &lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
For example:&lt;BR /&gt;
first row (month=1) : dataset a.sum1/dataset b.total1 = 1/10 = 0.1 &lt;BR /&gt;
first row (month=1) : dataset a.sum2/dataset b.total2 = 1/10 = 0.1...etc  &lt;BR /&gt;
second row (month=2) : dataset a.sum1/dataset b.total1 = 2/20 = 0.1 &lt;BR /&gt;
second row (month=2) : dataset a.sum2/dataset b.month2 = 2/20 = 0.1 ...etc&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
etc&lt;BR /&gt;
&lt;BR /&gt;
I guees arrays would be perfect for this, but how do you use arrays when there's two datasets involved? &lt;BR /&gt;
&lt;BR /&gt;
Do you have any ideas ? : )</description>
    <pubDate>Mon, 31 Aug 2009 11:21:39 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-08-31T11:21:39Z</dc:date>
    <item>
      <title>help with arrays!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/help-with-arrays/m-p/68257#M19548</link>
      <description>Hi guys.&lt;BR /&gt;
&lt;BR /&gt;
I have two data sets that looks like this:&lt;BR /&gt;
&lt;BR /&gt;
data a;&lt;BR /&gt;
input month monthly_sum sum1 sum2 sum3 sum4 sum5;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 10 1 1 1 1 1 &lt;BR /&gt;
2 20 2 2 2 2 .&lt;BR /&gt;
3 30 3 3 3 . .&lt;BR /&gt;
4 40 4 4 . . . &lt;BR /&gt;
5 50 5 . . . .&lt;BR /&gt;
6 60 . . . . . &lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
data b;&lt;BR /&gt;
input month monthly_sum total1 total2 total3 total4 total5;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 100 10 10 10 10 10 &lt;BR /&gt;
2 200 20 20 20 20 .&lt;BR /&gt;
3 300 30 30 30 . .&lt;BR /&gt;
4 400 40 40 . . . &lt;BR /&gt;
5 500 50 . . . .&lt;BR /&gt;
6 600 . . . . . &lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
What I want to do is create a new dataset that divides all the cells for sum1-sum5 for every row from dataset a with the "same location" cells for total1-total5 from dataset b.&lt;BR /&gt;
&lt;BR /&gt;
The result should look like this:&lt;BR /&gt;
data result;&lt;BR /&gt;
input month monthly_sum calc1 calc2 calc3 calc4 calc5;&lt;BR /&gt;
cards;&lt;BR /&gt;
1 10 0.1 0.1 0.1 0.1 0.1 &lt;BR /&gt;
2 20 0.1 0.1 0.1 0.1 .&lt;BR /&gt;
3 30 0.1 0.1 0.1 . .&lt;BR /&gt;
4 40 0.1 0.1 . . . &lt;BR /&gt;
5 50 0.1 . . . .&lt;BR /&gt;
6 60 . . . . . &lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
For example:&lt;BR /&gt;
first row (month=1) : dataset a.sum1/dataset b.total1 = 1/10 = 0.1 &lt;BR /&gt;
first row (month=1) : dataset a.sum2/dataset b.total2 = 1/10 = 0.1...etc  &lt;BR /&gt;
second row (month=2) : dataset a.sum1/dataset b.total1 = 2/20 = 0.1 &lt;BR /&gt;
second row (month=2) : dataset a.sum2/dataset b.month2 = 2/20 = 0.1 ...etc&lt;BR /&gt;
.&lt;BR /&gt;
.&lt;BR /&gt;
etc&lt;BR /&gt;
&lt;BR /&gt;
I guees arrays would be perfect for this, but how do you use arrays when there's two datasets involved? &lt;BR /&gt;
&lt;BR /&gt;
Do you have any ideas ? : )</description>
      <pubDate>Mon, 31 Aug 2009 11:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/help-with-arrays/m-p/68257#M19548</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-31T11:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: help with arrays!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/help-with-arrays/m-p/68258#M19549</link>
      <description>You could use the MERGE statement with a "BY MONTH;" and then set up arrays for the SUM's and TOTAL's.  You may have to sort each data set BY MONTH if they are not already in order.</description>
      <pubDate>Mon, 31 Aug 2009 12:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/help-with-arrays/m-p/68258#M19549</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-31T12:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: help with arrays!</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/help-with-arrays/m-p/68259#M19550</link>
      <description>Yeah thanks. I tried something like that, it seems to work : )&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table testing as select * from a as one inner join b as two  &lt;BR /&gt;
on one.month=two.month;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
data testar;&lt;BR /&gt;
set testing;&lt;BR /&gt;
array y(*) total1-total5; &lt;BR /&gt;
array z(*) sum1-sum5;&lt;BR /&gt;
array a{5} ;&lt;BR /&gt;
do i=1 to 5;          &lt;BR /&gt;
if z(i)&amp;gt;0 then a(i)=z(i)/y(i);&lt;BR /&gt;
else a(i)=0;&lt;BR /&gt;
end;&lt;BR /&gt;
run;</description>
      <pubDate>Mon, 31 Aug 2009 12:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/help-with-arrays/m-p/68259#M19550</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-08-31T12:40:58Z</dc:date>
    </item>
  </channel>
</rss>

