<?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 proc tabulate: weight with missings? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/883675#M349131</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i generate my results with proc-tabulate and a included weight-variable. Afterwards I compare my result with a friends result (made with another software) and I recognize a marginal difference. I researched a lot to find the reason for the difference and I found it: There is one person in my dataset that has no value in the weight-variable. Actually this person should not be part of the result, but it is. So I researched, how to avoid it and found the information:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;Prior to Version 7 of SAS, the procedure did not exclude the observations with missing weights from the count of observations.&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1hdr41psnyg4en137jaap5ia951.htm" target="_blank" rel="noopener"&gt;http://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1hdr41psnyg4en137jaap5ia951.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But my SAS-Version is 9.04.01M7P080520 (&lt;STRONG&gt;proc setinit; run;&lt;/STRONG&gt;). So: What is the reason for it? I mean...sure, alternative I always could exclude this person with the where-command. But this isnt a intuitive and smart option.&amp;nbsp;That would be error-prone because I would always have to think of exactly this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;STRONG&gt;correct&amp;nbsp;result:&lt;/STRONG&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;proc tabulate data=mz2020_j;
class wirtschaftsbereich ;
weight HRF_P_Sn;
classlev wirtschaftsbereich / style=[cellwidth=11cm];
var arbeitszeit_tats;
table (wirtschaftsbereich ="" all),	arbeitszeit_tats*mean n;
format 	wirtschaftsbereich Sektor.&lt;BR /&gt;&lt;U&gt;where HRF_P_Sn is not null&lt;/U&gt;;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;STRONG&gt;wrong result:&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=mz2020_j;
class wirtschaftsbereich ;
weight HRF_P_Sn;
classlev wirtschaftsbereich / style=[cellwidth=11cm];
var arbeitszeit_tats;
table (wirtschaftsbereich ="" all),	arbeitszeit_tats*mean n;
format 	wirtschaftsbereich Sektor.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jul 2023 08:53:02 GMT</pubDate>
    <dc:creator>Konkordanz</dc:creator>
    <dc:date>2023-07-06T08:53:02Z</dc:date>
    <item>
      <title>proc tabulate: weight with missings?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/883675#M349131</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i generate my results with proc-tabulate and a included weight-variable. Afterwards I compare my result with a friends result (made with another software) and I recognize a marginal difference. I researched a lot to find the reason for the difference and I found it: There is one person in my dataset that has no value in the weight-variable. Actually this person should not be part of the result, but it is. So I researched, how to avoid it and found the information:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;EM&gt;Prior to Version 7 of SAS, the procedure did not exclude the observations with missing weights from the count of observations.&lt;/EM&gt;"&lt;/P&gt;
&lt;P&gt;&lt;A href="http://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1hdr41psnyg4en137jaap5ia951.htm" target="_blank" rel="noopener"&gt;http://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/n1hdr41psnyg4en137jaap5ia951.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But my SAS-Version is 9.04.01M7P080520 (&lt;STRONG&gt;proc setinit; run;&lt;/STRONG&gt;). So: What is the reason for it? I mean...sure, alternative I always could exclude this person with the where-command. But this isnt a intuitive and smart option.&amp;nbsp;That would be error-prone because I would always have to think of exactly this case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;STRONG&gt;correct&amp;nbsp;result:&lt;/STRONG&gt;&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;proc tabulate data=mz2020_j;
class wirtschaftsbereich ;
weight HRF_P_Sn;
classlev wirtschaftsbereich / style=[cellwidth=11cm];
var arbeitszeit_tats;
table (wirtschaftsbereich ="" all),	arbeitszeit_tats*mean n;
format 	wirtschaftsbereich Sektor.&lt;BR /&gt;&lt;U&gt;where HRF_P_Sn is not null&lt;/U&gt;;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;STRONG&gt;wrong result:&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=mz2020_j;
class wirtschaftsbereich ;
weight HRF_P_Sn;
classlev wirtschaftsbereich / style=[cellwidth=11cm];
var arbeitszeit_tats;
table (wirtschaftsbereich ="" all),	arbeitszeit_tats*mean n;
format 	wirtschaftsbereich Sektor.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2023 08:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/883675#M349131</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2023-07-06T08:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: weight with missings?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/883685#M349132</link>
      <description>&lt;P&gt;Why do you include the WEIGHT variable in the VAR statement?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2023 08:47:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/883685#M349132</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-07-06T08:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: weight with missings?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/883686#M349133</link>
      <description>&lt;P&gt;Thx for answering!&lt;/P&gt;
&lt;P&gt;And right, I corrected it in the initial post. But it doesn't change the problem I described. &lt;/P&gt;</description>
      <pubDate>Thu, 06 Jul 2023 08:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/883686#M349133</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2023-07-06T08:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: weight with missings?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/883703#M349138</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
Your code is not right ,
if you want take into account of missing value with 
analysis variable,you need take 'n' be with it via ().
Check the following:
*/

data have;
set sashelp.class;
w=1;
if _n_=10 then w=.;
run;

proc tabulate data=have;
class age ;
weight w;
classlev age / style=[cellwidth=11cm];
var weight;
table (age ="" all), weight*mean n;
where w is not null;
run;


proc tabulate data=have;
class age ;
weight w;
classlev age / style=[cellwidth=11cm];
var weight;
table (age ="" all),weight*(mean n);  /*&amp;lt;--- Check this ,need 'n' within () */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Jul 2023 12:04:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/883703#M349138</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-07-06T12:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: weight with missings?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/884139#M349266</link>
      <description>&lt;P&gt;Wow, only the missing bracket was the reason.Thank you! &lt;/P&gt;
&lt;P&gt;But what is actually the difference between these two codes?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc tabulate data=have;
class age ;
weight w;
classlev age / style=[cellwidth=11cm];
var weight;
table (age ="" all),weight*(mean n); &lt;STRONG&gt;/*with bracket*/&lt;/STRONG&gt;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;proc tabulate data=have;
class age ;
weight w;
classlev age / style=[cellwidth=11cm];
var weight;
table (age ="" all),weight*mean n; &lt;STRONG&gt;/*without bracket*/&lt;/STRONG&gt;
run;&lt;/PRE&gt;
&lt;P&gt;With the bracketing, the n refers only to "weight" and without brackets the n refers to all involved variables? That means...without parentheses, all cases that have a value in any specified variable are involved?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 06:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/884139#M349266</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2023-07-10T06:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: proc tabulate: weight with missings?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/884169#M349274</link>
      <description>table (age ="" all),weight*(mean n); /*with bracket*/&lt;BR /&gt;&lt;BR /&gt;Will take into account of missing value of both AGE and WEIGHT since bracket belong to WEIGHT.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;table (age ="" all),weight*mean n; /*without bracket*/&lt;BR /&gt;&lt;BR /&gt;Only consider about AGE is missing or not sine n is not in bracket.</description>
      <pubDate>Mon, 10 Jul 2023 11:46:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-tabulate-weight-with-missings/m-p/884169#M349274</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-07-10T11:46:39Z</dc:date>
    </item>
  </channel>
</rss>

