<?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: Grouping variables together to perform calculations on the group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270933#M269458</link>
    <description>Hi Kurt, thank you for your quick replies. After using the single quotes, I am still getting following error message.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE,&lt;BR /&gt;GT, LE, LT, MAX, MIN, NE, NG, NL, OR, ^=, |, ||, ~=.&lt;BR /&gt;&lt;BR /&gt;ERROR 253-185: The EXECUTE subroutine call has too many arguments.&lt;BR /&gt;</description>
    <pubDate>Tue, 17 May 2016 11:24:01 GMT</pubDate>
    <dc:creator>Rohit_R</dc:creator>
    <dc:date>2016-05-17T11:24:01Z</dc:date>
    <item>
      <title>Grouping variables together to perform calculations on the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270923#M269454</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with variables denoting the statuses for the observations as at a month end. The key variables are 'StatusAtMonthend' and 'DaysAtStatusAtMonthend' which are repeated for each of the month ends going back several years. I want to calculate mean and median for the&amp;nbsp;&lt;SPAN&gt;'DaysAtStatusAtMonth' variable for each of the statuses in the&amp;nbsp;'StatusAtMonthend' variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I created two&amp;nbsp;arrays in a datastep holding all the 'StatusAtMonthEnd' in one array and the &lt;SPAN&gt;'DaysAtStatusAtMonthend' in another. However, I do not know how to&amp;nbsp;calculate the mean/median in the data step, I think it requires a proc means, but it will be inefficient to write a proc means for each of the month ends for several years.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;data stats;&lt;BR /&gt;set statuses;&lt;BR /&gt;array TCs {*} Status2015_01-Status2015_12;&lt;BR /&gt;array DaysTC {*} DaysAtStatus&lt;SPAN&gt;2015_01-DaysAt&lt;SPAN&gt;Status&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;_12&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;I want the mean/median days spent in each of the statuses at each of the month ends.&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Please can someone point me in the right direction?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;(Enterprise Guide 7.1)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 10:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270923#M269454</guid>
      <dc:creator>Rohit_R</dc:creator>
      <dc:date>2016-05-17T10:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping variables together to perform calculations on the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270927#M269455</link>
      <description>&lt;P&gt;Transpose the dataset from wide to long format with proc transpose, then you can use proc means.&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 11:02:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270927#M269455</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-05-17T11:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping variables together to perform calculations on the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270928#M269456</link>
      <description>I played around a bit and thought of a way, however I am getting an error 'Too many arguments' for the execute subroutine.&lt;BR /&gt;&lt;BR /&gt;%macro mean_med(dataset, status, DaysAtstatus);&lt;BR /&gt;proc means data=&amp;amp;dataset mean median;&lt;BR /&gt;class &amp;amp;status;&lt;BR /&gt;var &amp;amp;DaysAtStatus;&lt;BR /&gt;run;&lt;BR /&gt;%mend mean_med;&lt;BR /&gt;&lt;BR /&gt;data stats1;&lt;BR /&gt;set stats;&lt;BR /&gt;array STs (*) ST2015_01-ST2015_12;&lt;BR /&gt;array DaysST (*) DaysAtStatus_2015_01-DaysAtTerritory_2015_12;&lt;BR /&gt;do i=1 to 12;&lt;BR /&gt;call execute("%mean_med(status1" || "," || STs(i)|| "," DaysST(i)|| ")");&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;Am I missing something in the call execute code?&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 17 May 2016 11:08:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270928#M269456</guid>
      <dc:creator>Rohit_R</dc:creator>
      <dc:date>2016-05-17T11:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping variables together to perform calculations on the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270932#M269457</link>
      <description>&lt;P&gt;When executing a macro with call execute, use single quotes for the macro call, or the macro will be expanded before the data step (that contains the call execute) runs.&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 11:20:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270932#M269457</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-05-17T11:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping variables together to perform calculations on the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270933#M269458</link>
      <description>Hi Kurt, thank you for your quick replies. After using the single quotes, I am still getting following error message.&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE,&lt;BR /&gt;GT, LE, LT, MAX, MIN, NE, NG, NL, OR, ^=, |, ||, ~=.&lt;BR /&gt;&lt;BR /&gt;ERROR 253-185: The EXECUTE subroutine call has too many arguments.&lt;BR /&gt;</description>
      <pubDate>Tue, 17 May 2016 11:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270933#M269458</guid>
      <dc:creator>Rohit_R</dc:creator>
      <dc:date>2016-05-17T11:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping variables together to perform calculations on the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270934#M269459</link>
      <description>&lt;P&gt;You miss a concatenation operator between the second comma and DaysST(i).&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 11:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270934#M269459</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-05-17T11:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping variables together to perform calculations on the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270935#M269460</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you have missing || before DaysST(i) in the call execute syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway i don't think you will get the desired results with this aproach...&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 11:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270935#M269460</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-05-17T11:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping variables together to perform calculations on the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270972#M269461</link>
      <description>Thanks Loko, could you suggest an alternative?</description>
      <pubDate>Tue, 17 May 2016 13:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/270972#M269461</guid>
      <dc:creator>Rohit_R</dc:creator>
      <dc:date>2016-05-17T13:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Grouping variables together to perform calculations on the group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/271003#M269462</link>
      <description>&lt;P&gt;It would help to give a few example records and what the expected output should be.&lt;/P&gt;</description>
      <pubDate>Tue, 17 May 2016 15:02:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Grouping-variables-together-to-perform-calculations-on-the-group/m-p/271003#M269462</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-17T15:02:54Z</dc:date>
    </item>
  </channel>
</rss>

