<?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 take mean of specific date in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-take-mean-of-specific-date/m-p/852685#M37485</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
    class date; /* Your date variable name goes here */
    var x; /* The names of the variables from which you want to compute means */
    output out=want mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 08 Jan 2023 15:53:57 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-01-08T15:53:57Z</dc:date>
    <item>
      <title>how to take mean of specific date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-take-mean-of-specific-date/m-p/852684#M37484</link>
      <description>&lt;P&gt;Hi, I wanted to ask that I am trying to take mean of different observations done on same date. I have data for 6 months and there are many observations of every date. Now I want to take mean of every date so that data is minimized. If anyone can tell me the code.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2023 10:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-take-mean-of-specific-date/m-p/852684#M37484</guid>
      <dc:creator>farwa</dc:creator>
      <dc:date>2023-01-08T10:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to take mean of specific date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-take-mean-of-specific-date/m-p/852685#M37485</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
    class date; /* Your date variable name goes here */
    var x; /* The names of the variables from which you want to compute means */
    output out=want mean=;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Jan 2023 15:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-take-mean-of-specific-date/m-p/852685#M37485</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-08T15:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to take mean of specific date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-take-mean-of-specific-date/m-p/852687#M37486</link>
      <description>&lt;P&gt;Just for completeness (using MEANS/SUMMARY is recommended):&lt;/P&gt;
&lt;P&gt;DATA step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
by date;
run;

data want;
set have (rename=(x=_x));
by date;
if first.date
then do;
  x = _x;
  count = 1;
end;
else do;
  x + _x;
  count + 1;
end;
if last.date;
x = x / count;
drop _x count;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(the two SUM statements in the ELSE cause an implied RETAIN of the variables)&lt;/P&gt;
&lt;P&gt;SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    date,
    mean(x) as x
  from have
  group by date
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Jan 2023 12:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-take-mean-of-specific-date/m-p/852687#M37486</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-08T12:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to take mean of specific date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-take-mean-of-specific-date/m-p/852690#M37487</link>
      <description>&lt;P&gt;I agree that PROC SUMMARY/PROC MEANS is the preferred approach, for many reasons. One of those reasons: if you have multiple variables for which means are needed, it is also much less typing than the other approaches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data step code, as provided, gives the wrong answer if there are missing values in the data.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2023 12:32:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-take-mean-of-specific-date/m-p/852690#M37487</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-08T12:32:26Z</dc:date>
    </item>
  </channel>
</rss>

