<?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: Is an array the best way to solve this problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827981#M327065</link>
    <description>&lt;P&gt;Your data isn't really in the best shape for analysis. You need to transform your data from wide format, where your data is in separate variables for each month, to long format which would look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Team_ID&lt;/P&gt;
&lt;P&gt;Team_Name&lt;/P&gt;
&lt;P&gt;Month - like 01Jan2021&lt;/P&gt;
&lt;P&gt;Amount_Raised&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you data is like this analysis is easy and you don't need arrays. Please supply some sample data if you want help transforming it..&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2022 20:17:10 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2022-08-09T20:17:10Z</dc:date>
    <item>
      <title>Is an array the best way to solve this problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827874#M327010</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm using SAS Enterprise Guide version 8.3.&lt;/P&gt;&lt;P&gt;Below is t&lt;/P&gt;&lt;P&gt;I have two data sets. One list is of teams. There are over 300 teams.&amp;nbsp; One dataset list the teams and the dollar amount they raised over the past 19 months. The other spreadsheet lists the same teams and the number of members they had each of those 19 months.&amp;nbsp; I was able to combine the two datasets into one so it has the following columns:&lt;/P&gt;&lt;P&gt;Team ID&lt;/P&gt;&lt;P&gt;Team Name&lt;/P&gt;&lt;P&gt;Month 1 amount raised (The variable is name is 202101.&amp;nbsp; This stands for the year and month YYYYMM&amp;nbsp; )&lt;/P&gt;&lt;P&gt;Month 2 amount raised (and on for 19 months) (The variable names are&amp;nbsp; 202102 -202210 )&lt;/P&gt;&lt;P&gt;Number of members month 1&amp;nbsp; (The variable name is Jan2021)&lt;/P&gt;&lt;P&gt;number of members month 2&amp;nbsp;(The variable name is Feb2021)0&lt;/P&gt;&lt;P&gt;and on for 19 months.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to calculate how much as raised each month on a per member basis for each team. This variable would be per member per month (pmpm) So I would be adding another 19 columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I started out with the following, but I then I wasn't sure what to do or even if an array is the best way to calculate the per member per month over the 19 months (Jan 2021 through August 2022)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data Amt_Raised_A;&lt;BR /&gt;set&amp;nbsp; Amt_raised_B;&lt;BR /&gt;array pmpm_array pmpm1 - pmpm19;&lt;BR /&gt;do i=1 to 19;&lt;BR /&gt;pmpm =&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&amp;nbsp; Thanks so much,&lt;/P&gt;&lt;P&gt;Diane&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 15:09:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827874#M327010</guid>
      <dc:creator>abqdiane</dc:creator>
      <dc:date>2022-08-09T15:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Is an array the best way to solve this problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827887#M327018</link>
      <description>&lt;P&gt;How about this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Amt_Raised_A;
set  Amt_raised_B;
array pmpm_array pmpm1 - pmpm19;
array month 202101--202210;
array members jan2021--Oct2022;
do i=1 to 19;
pmpm(i) = month(i)/members(i);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code is of course UNTESTED as I don't have your SAS data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, this is a great example of how this whole thing would be much simpler (no arrays needed) if you use a long data set (with a variable named MONTH) rather than a wide data set where the calendar information is part of the variable names. A good layout in Excel is not necessarily a good layout in SAS.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 15:30:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827887#M327018</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-08-09T15:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Is an array the best way to solve this problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827891#M327021</link>
      <description>Wow - thanks so much I'll give it a try. Good point about the layout.&lt;BR /&gt;I'll let you know how it goes.&lt;BR /&gt;Diane&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Aug 2022 15:35:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827891#M327021</guid>
      <dc:creator>abqdiane</dc:creator>
      <dc:date>2022-08-09T15:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: Is an array the best way to solve this problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827981#M327065</link>
      <description>&lt;P&gt;Your data isn't really in the best shape for analysis. You need to transform your data from wide format, where your data is in separate variables for each month, to long format which would look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Team_ID&lt;/P&gt;
&lt;P&gt;Team_Name&lt;/P&gt;
&lt;P&gt;Month - like 01Jan2021&lt;/P&gt;
&lt;P&gt;Amount_Raised&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you data is like this analysis is easy and you don't need arrays. Please supply some sample data if you want help transforming it..&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 20:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827981#M327065</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-08-09T20:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Is an array the best way to solve this problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827991#M327066</link>
      <description>thanks - when I get a chance I'll try to reformat it. I appreciate the&lt;BR /&gt;suggestions.&lt;BR /&gt;Diane&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Aug 2022 21:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-an-array-the-best-way-to-solve-this-problem/m-p/827991#M327066</guid>
      <dc:creator>abqdiane</dc:creator>
      <dc:date>2022-08-09T21:05:45Z</dc:date>
    </item>
  </channel>
</rss>

