<?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: how to calculate a mean per semester in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-a-mean-per-semester/m-p/412871#M279897</link>
    <description>&lt;P&gt;Use INTNX() to make a group variable then PROC SUMMARY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date : date9. value;
format date date9.;
cards;
05jun2017 21
12nov2017 43
21feb2016 32
21mar2017 3
;
run;

data have;
 set have;
 group=intnx('semiyear',date,0);
 format group date9.;
run;

proc summary data=have nway;
class group;
var value;
output out=want mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 13 Nov 2017 13:02:24 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-11-13T13:02:24Z</dc:date>
    <item>
      <title>how to calculate a mean per semester</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-a-mean-per-semester/m-p/412845#M279894</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to calculate the mean per period of the following table :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="test.PNG" style="width: 189px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16597iB2347C6B702057AC/image-size/large?v=v2&amp;amp;px=999" role="button" title="test.PNG" alt="test.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I would like to get a table like this :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="date.PNG" style="width: 239px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16598i08AC544DB52D60F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="date.PNG" alt="date.PNG" /&gt;&lt;/span&gt;&amp;nbsp;Thank you for your help&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 11:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-a-mean-per-semester/m-p/412845#M279894</guid>
      <dc:creator>madix</dc:creator>
      <dc:date>2017-11-13T11:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate a mean per semester</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-a-mean-per-semester/m-p/412862#M279895</link>
      <description>&lt;P&gt;How are these periods defined? Why is june included in the last half year period in the first group but not in the last?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a clear pattern of how your groups are defined, you can use PROC TIMESERIES.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, use a data step to group the periods and use PROC MEANS.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Nov 2017 12:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-a-mean-per-semester/m-p/412862#M279895</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-11-13T12:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate a mean per semester</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-a-mean-per-semester/m-p/412863#M279896</link>
      <description>&lt;P&gt;You can create the date_semester variable and calculate mean by it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
 set have;
       length semstr $7;
       mon = put(date,yymmn6.);
       if  '200507' le mon le '200512' then semstr = '2005_s2'; else
       if  '200601' le mon le '200606' then semstr = '2006_s1'; else
       if  '200606' le mon le '200612' then semstr = '2006_s2';
run;

proc means data=temp;
     class semstr;
     var    score_value;
     output out=want mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Nov 2017 12:11:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-a-mean-per-semester/m-p/412863#M279896</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-11-13T12:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: how to calculate a mean per semester</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-a-mean-per-semester/m-p/412871#M279897</link>
      <description>&lt;P&gt;Use INTNX() to make a group variable then PROC SUMMARY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date : date9. value;
format date date9.;
cards;
05jun2017 21
12nov2017 43
21feb2016 32
21mar2017 3
;
run;

data have;
 set have;
 group=intnx('semiyear',date,0);
 format group date9.;
run;

proc summary data=have nway;
class group;
var value;
output out=want mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Nov 2017 13:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-calculate-a-mean-per-semester/m-p/412871#M279897</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-13T13:02:24Z</dc:date>
    </item>
  </channel>
</rss>

