<?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: PROC Means is treating each observation as separate? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-Means-is-treating-each-observation-as-separate/m-p/628505#M185738</link>
    <description>&lt;P&gt;Did you intend to use ID as a CLASS variable instead of an analysis variable?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
  input ID $ month_num Var1 Var1_Counter;
CARDS;
01 1 . .
01 2 3.5 1
01 3 . 1
01 4 1.4 2
01 5 . 2
02 1 . .
02 2 1.2 1
02 3 1.4 2
02 4 1.7 3
02 5 5.1 4
;

proc means data=temp;
  class id;
  output out=want;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You still won't get the value of N to be 2, unless one of your variables only has 2 non-missing values for one of the IDs.&lt;/P&gt;
&lt;P&gt;But you will get output for ID=2 and another for ID=1.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;The MEANS Procedure

              N
ID          Obs    Variable         N            Mean         Std Dev         Minimum         Maximum
-----------------------------------------------------------------------------------------------------
01            5    month_num        5       3.0000000       1.5811388       1.0000000       5.0000000
                   Var1             2       2.4500000       1.4849242       1.4000000       3.5000000
                   Var1_Counter     4       1.5000000       0.5773503       1.0000000       2.0000000

02            5    month_num        5       3.0000000       1.5811388       1.0000000       5.0000000
                   Var1             4       2.3500000       1.8448125       1.2000000       5.1000000
                   Var1_Counter     4       2.5000000       1.2909944       1.0000000       4.0000000
-----------------------------------------------------------------------------------------------------
 
                                            month_                Var1_
Obs    ID    _TYPE_    _FREQ_    _STAT_      num        Var1     Counter

  1             0        10       N        10.0000    6.00000    8.00000
  2             0        10       MIN       1.0000    1.20000    1.00000
  3             0        10       MAX       5.0000    5.10000    4.00000
  4             0        10       MEAN      3.0000    2.38333    2.00000
  5             0        10       STD       1.4907    1.57660    1.06904
  6    01       1         5       N         5.0000    2.00000    4.00000
  7    01       1         5       MIN       1.0000    1.40000    1.00000
  8    01       1         5       MAX       5.0000    3.50000    2.00000
  9    01       1         5       MEAN      3.0000    2.45000    1.50000
 10    01       1         5       STD       1.5811    1.48492    0.57735
 11    02       1         5       N         5.0000    4.00000    4.00000
 12    02       1         5       MIN       1.0000    1.20000    1.00000
 13    02       1         5       MAX       5.0000    5.10000    4.00000
 14    02       1         5       MEAN      3.0000    2.35000    2.50000
 15    02       1         5       STD       1.5811    1.84481    1.29099
&lt;/PRE&gt;</description>
    <pubDate>Sun, 01 Mar 2020 01:45:02 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-03-01T01:45:02Z</dc:date>
    <item>
      <title>PROC Means is treating each observation as separate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-Means-is-treating-each-observation-as-separate/m-p/628504#M185737</link>
      <description>&lt;P&gt;So when I run a PROC MEANS on the following data:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
infile DATALINES dsd missover;
input ID DATE(month_num) Var1 Var1_Counter;
CARDS;
01, 1, ., .
01, 2, 3.5, 1
01, 3, ., 1
01, 4, 1.4, 2
01, 5, ., 2
02, 1, ., .
02, 2, 1.2, 1
02, 3, 1.4, 2
02, 4, 1.7, 3
02, 5, 5.1, 4
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Using:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC MEANS data = have ;
	var ID DATE Var1 Var1_counter;
	output out = want;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My "N" column, which should be giving me 2 (since there are only 2 IDs) is actually giving me 10, for the total number of observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know why? Additionally, how can my PROC means to also include _TYPE_ and _FREQ_ in the output table?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 01 Mar 2020 01:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-Means-is-treating-each-observation-as-separate/m-p/628504#M185737</guid>
      <dc:creator>UniversitySas</dc:creator>
      <dc:date>2020-03-01T01:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: PROC Means is treating each observation as separate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-Means-is-treating-each-observation-as-separate/m-p/628505#M185738</link>
      <description>&lt;P&gt;Did you intend to use ID as a CLASS variable instead of an analysis variable?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
  input ID $ month_num Var1 Var1_Counter;
CARDS;
01 1 . .
01 2 3.5 1
01 3 . 1
01 4 1.4 2
01 5 . 2
02 1 . .
02 2 1.2 1
02 3 1.4 2
02 4 1.7 3
02 5 5.1 4
;

proc means data=temp;
  class id;
  output out=want;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You still won't get the value of N to be 2, unless one of your variables only has 2 non-missing values for one of the IDs.&lt;/P&gt;
&lt;P&gt;But you will get output for ID=2 and another for ID=1.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;The MEANS Procedure

              N
ID          Obs    Variable         N            Mean         Std Dev         Minimum         Maximum
-----------------------------------------------------------------------------------------------------
01            5    month_num        5       3.0000000       1.5811388       1.0000000       5.0000000
                   Var1             2       2.4500000       1.4849242       1.4000000       3.5000000
                   Var1_Counter     4       1.5000000       0.5773503       1.0000000       2.0000000

02            5    month_num        5       3.0000000       1.5811388       1.0000000       5.0000000
                   Var1             4       2.3500000       1.8448125       1.2000000       5.1000000
                   Var1_Counter     4       2.5000000       1.2909944       1.0000000       4.0000000
-----------------------------------------------------------------------------------------------------
 
                                            month_                Var1_
Obs    ID    _TYPE_    _FREQ_    _STAT_      num        Var1     Counter

  1             0        10       N        10.0000    6.00000    8.00000
  2             0        10       MIN       1.0000    1.20000    1.00000
  3             0        10       MAX       5.0000    5.10000    4.00000
  4             0        10       MEAN      3.0000    2.38333    2.00000
  5             0        10       STD       1.4907    1.57660    1.06904
  6    01       1         5       N         5.0000    2.00000    4.00000
  7    01       1         5       MIN       1.0000    1.40000    1.00000
  8    01       1         5       MAX       5.0000    3.50000    2.00000
  9    01       1         5       MEAN      3.0000    2.45000    1.50000
 10    01       1         5       STD       1.5811    1.48492    0.57735
 11    02       1         5       N         5.0000    4.00000    4.00000
 12    02       1         5       MIN       1.0000    1.20000    1.00000
 13    02       1         5       MAX       5.0000    5.10000    4.00000
 14    02       1         5       MEAN      3.0000    2.35000    2.50000
 15    02       1         5       STD       1.5811    1.84481    1.29099
&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Mar 2020 01:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-Means-is-treating-each-observation-as-separate/m-p/628505#M185738</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-03-01T01:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: PROC Means is treating each observation as separate?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-Means-is-treating-each-observation-as-separate/m-p/628506#M185739</link>
      <description>I see. Maybe I am misunderstanding what the output is supposed to say. I don't want my ID as a CLASS variable, so I think I made a mistake in my prior results. Thanks for the clarification!</description>
      <pubDate>Sun, 01 Mar 2020 02:16:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-Means-is-treating-each-observation-as-separate/m-p/628506#M185739</guid>
      <dc:creator>UniversitySas</dc:creator>
      <dc:date>2020-03-01T02:16:41Z</dc:date>
    </item>
  </channel>
</rss>

