<?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 do a chi-square for specific variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-chi-square-for-specific-variable/m-p/874671#M345600</link>
    <description>&lt;P&gt;You may want to describe what you are attempting and what you mean by "specfic variable"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know that you likely don't like that your Log shows something like:&lt;/P&gt;
&lt;PRE&gt;NOTE: No statistics are computed for Gender * Prices100 because Prices100 has less than 2 nonmissing levels.

&lt;/PRE&gt;
&lt;P&gt;You have restricted one of the variables to only allow one level, "RM101-RM400", and when you have a two-way chi-square the calculations just do not work that way as you are introducing a divide-by-zero condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can run a chi-square on a single variable such as:&lt;/P&gt;
&lt;PRE&gt;Proc freq data=sashelp.class;
   tables age /chisq;
run;&lt;/PRE&gt;
&lt;P&gt;And the results reflect the levels of the single variable.&lt;/P&gt;
&lt;P&gt;I suspect that you may have wanted if the question you wanted answered was "is the distribution of Gender the same/different when Prices100 has this specific value".&lt;/P&gt;
&lt;PRE&gt;proc freq data=AddnewPrice;
   TABLES Gender
       /chisq;
    where Prices100 = "RM201-RM400";
run;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/441747"&gt;@ChingYee&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;/* Frequuency for Prices100 */&lt;BR /&gt;proc freq data=AddnewPrice;&lt;BR /&gt;TABLES Gender*Prices100&lt;BR /&gt;/chisq;&lt;BR /&gt;where Prices100 = "RM201-RM400";&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 May 2023 14:41:08 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-05-09T14:41:08Z</dc:date>
    <item>
      <title>How to do a chi-square for specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-chi-square-for-specific-variable/m-p/874608#M345580</link>
      <description>&lt;P&gt;/* Frequuency for Prices100 */&lt;BR /&gt;proc freq data=AddnewPrice;&lt;BR /&gt;TABLES Gender*Prices100&lt;BR /&gt;/chisq;&lt;BR /&gt;where Prices100 = "RM201-RM400";&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 07:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-chi-square-for-specific-variable/m-p/874608#M345580</guid>
      <dc:creator>ChingYee</dc:creator>
      <dc:date>2023-05-09T07:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a chi-square for specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-chi-square-for-specific-variable/m-p/874635#M345588</link>
      <description>&lt;P&gt;What is wrong with the code you show us?&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 10:27:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-chi-square-for-specific-variable/m-p/874635#M345588</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-09T10:27:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a chi-square for specific variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-chi-square-for-specific-variable/m-p/874671#M345600</link>
      <description>&lt;P&gt;You may want to describe what you are attempting and what you mean by "specfic variable"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know that you likely don't like that your Log shows something like:&lt;/P&gt;
&lt;PRE&gt;NOTE: No statistics are computed for Gender * Prices100 because Prices100 has less than 2 nonmissing levels.

&lt;/PRE&gt;
&lt;P&gt;You have restricted one of the variables to only allow one level, "RM101-RM400", and when you have a two-way chi-square the calculations just do not work that way as you are introducing a divide-by-zero condition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can run a chi-square on a single variable such as:&lt;/P&gt;
&lt;PRE&gt;Proc freq data=sashelp.class;
   tables age /chisq;
run;&lt;/PRE&gt;
&lt;P&gt;And the results reflect the levels of the single variable.&lt;/P&gt;
&lt;P&gt;I suspect that you may have wanted if the question you wanted answered was "is the distribution of Gender the same/different when Prices100 has this specific value".&lt;/P&gt;
&lt;PRE&gt;proc freq data=AddnewPrice;
   TABLES Gender
       /chisq;
    where Prices100 = "RM201-RM400";
run;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/441747"&gt;@ChingYee&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;/* Frequuency for Prices100 */&lt;BR /&gt;proc freq data=AddnewPrice;&lt;BR /&gt;TABLES Gender*Prices100&lt;BR /&gt;/chisq;&lt;BR /&gt;where Prices100 = "RM201-RM400";&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 14:41:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-do-a-chi-square-for-specific-variable/m-p/874671#M345600</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-09T14:41:08Z</dc:date>
    </item>
  </channel>
</rss>

