<?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: Weird Chi Square requests in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/746351#M234120</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/106227"&gt;@klongway&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you always compare the 1000 observations with &lt;FONT face="courier new,courier"&gt;sample=2&lt;/FONT&gt; to the remaining 1500 with &lt;FONT face="courier new,courier"&gt;sample=1&lt;/FONT&gt;. The example below shows how to do this comparison for a categorical variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test data for demonstration */

data have;
set sashelp.heart(obs=2500 rename=(status=employment));
sample=1+(_n_&amp;lt;=1000);
run;

/* Perform chi-square test */

proc freq data=have;
tables sample*employment / chisq;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 07 Jun 2021 18:56:15 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-06-07T18:56:15Z</dc:date>
    <item>
      <title>Weird Chi Square requests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/746344#M234117</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset that contains the sample (2,500 participants), in which I have a subsample that I'm using for analysis (1000 participants). I am trying to see if there are statistically significant differences between the whole sample and my subsample. I am using T tests for my interval variables, but have a lot of categorical variables, so I am trying to use Chi square to see if there are significant differences.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To differentiate between the whole sample and the subsample I have a new variable called "sample" and if the value in the "sample" column is 1 then that participant is part of the large sample but not the subsample, and if the value in the "sample" column is 2 then the participant is part of the subsample.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For t tests I used the class statement saying "class sample; var age" which seems to have worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a similar way to do this for Chi Square?&amp;nbsp; I want to compare employment (employed or not) for sample 1 and sample 2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jun 2021 18:32:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/746344#M234117</guid>
      <dc:creator>klongway</dc:creator>
      <dc:date>2021-06-07T18:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: Weird Chi Square requests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/746351#M234120</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/106227"&gt;@klongway&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you always compare the 1000 observations with &lt;FONT face="courier new,courier"&gt;sample=2&lt;/FONT&gt; to the remaining 1500 with &lt;FONT face="courier new,courier"&gt;sample=1&lt;/FONT&gt;. The example below shows how to do this comparison for a categorical variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create test data for demonstration */

data have;
set sashelp.heart(obs=2500 rename=(status=employment));
sample=1+(_n_&amp;lt;=1000);
run;

/* Perform chi-square test */

proc freq data=have;
tables sample*employment / chisq;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jun 2021 18:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/746351#M234120</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-06-07T18:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Weird Chi Square requests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/746390#M234137</link>
      <description>&lt;P&gt;This is so helpful!!! Thank you!!! I'm running into problems with some of my variables when doing this- some are working, others are not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have&amp;nbsp;&lt;/P&gt;&lt;P&gt;data file2;&lt;/P&gt;&lt;P&gt;set file1;&lt;/P&gt;&lt;P&gt;if dep=. then sample=2;&lt;/P&gt;&lt;P&gt;if dep=1 then sample=1;&lt;/P&gt;&lt;P&gt;if dep=2 then sample=1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;I then run a table&lt;/P&gt;&lt;P&gt;Proc freq data=file2;&lt;/P&gt;&lt;P&gt;tables sample;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;And the table shows all of my 2500 samples into sample 1 or sample 2.&lt;/P&gt;&lt;P&gt;When I try to run the chi square for employment, though, sample 2 comes up blank.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did:&lt;/P&gt;&lt;P&gt;proc freq data=file2&lt;/P&gt;&lt;P&gt;tables sample*emp/chisq;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the table comes up with sample 2 empty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked the file 2 and I have plenty of people who answered the employment question in sample 2, so it isn't that there isn't any data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 03:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/746390#M234137</guid>
      <dc:creator>klongway</dc:creator>
      <dc:date>2021-06-08T03:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Weird Chi Square requests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/746408#M234144</link>
      <description>&lt;P&gt;To get a quick overview of several categorical variables I often use PROC FREQ with the MISSING and LIST options in the TABLES statement.&lt;/P&gt;
&lt;P&gt;So I would run&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=file2;
tables dep*sample*emp / missing list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and examine the resulting output. What does it look like for your &lt;FONT face="courier new,courier"&gt;file2&lt;/FONT&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 07:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/746408#M234144</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-06-08T07:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Weird Chi Square requests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/747515#M234621</link>
      <description>&lt;P&gt;Thank you so much! When I run that I get: a chart with&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample 2-full time-400&lt;/P&gt;&lt;P&gt;Sample 2-parttime-400&lt;/P&gt;&lt;P&gt;Sample 2- not working-700&lt;/P&gt;&lt;P&gt;Sample 1-missing=1500&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So It is pulling all of sample 2 but only has the "missing" in sample 1. But the "missing" in sample 2 adds up to the total number in the dataset in sample 2....!!! Is it possible everyone in Sample 1 did not answer this question?! Ahh!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jun 2021 02:52:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/747515#M234621</guid>
      <dc:creator>klongway</dc:creator>
      <dc:date>2021-06-12T02:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: Weird Chi Square requests</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/747519#M234625</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/106227"&gt;@klongway&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;... When I run that I get: a chart with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample 2-full time-400&lt;/P&gt;
&lt;P&gt;Sample 2-parttime-400&lt;/P&gt;
&lt;P&gt;Sample 2- not working-700&lt;/P&gt;
&lt;P&gt;Sample 1-missing=1500&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Assuming that "Sample 2" in the above PROC FREQ output refers to your "subsample" consisting of 1000 participants, I would be wondering why the corresponding frequencies, 400, 400 and 700, add up to 1500, not 1000.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jun 2021 07:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Weird-Chi-Square-requests/m-p/747519#M234625</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-06-12T07:22:57Z</dc:date>
    </item>
  </channel>
</rss>

