<?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 compare two categorical values between two different sites in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815189#M321758</link>
    <description>&lt;P&gt;So what do you want to test? You didn't answer that question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to test 300/900 compared to 50/250?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or do you want to test 300/350 compared to 50/350?&lt;/P&gt;</description>
    <pubDate>Thu, 26 May 2022 11:40:40 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-05-26T11:40:40Z</dc:date>
    <item>
      <title>How to compare two categorical values between two different sites</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815023#M321716</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to compare the severity of deer damage between two sites, but I am confised as to how to go about it. Basically the data looks like this:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Site&lt;/TD&gt;&lt;TD&gt;Severity&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Planted&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Planted&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Planted&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Planted&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Planted&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Planted&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Planted&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to compare if the scores of zero are different between the two sites (p-value for 0, 1 and 2). The same goes for the score of 1 and 2 (individually). The number of observations in the non-intervention compared to the planted are very different (900 vs. 240), so I assume it is the frequency I am looking to compare.&lt;/P&gt;&lt;P&gt;I have tried writing a chi-square test in this manor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;proc freq data=Thesis;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;tables severity*site / chisq nocol norow nopercent;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;weight severity; where severity='1'; run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I do this all it gives me is this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lysegroentblad_0-1653485637347.png" style="width: 227px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71754iD3BF16591F400FC2/image-dimensions/227x128?v=v2" width="227" height="128" role="button" title="Lysegroentblad_0-1653485637347.png" alt="Lysegroentblad_0-1653485637347.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Which is just the number of observations that equals 1 in each site.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried doing this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;proc glm DATA = Thesis;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Class site;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Model severity = site; by severity; RUN;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That gives me this, which is not useful at all:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lysegroentblad_1-1653485897939.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71755iC9F3EA4D50FA3AC0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lysegroentblad_1-1653485897939.png" alt="Lysegroentblad_1-1653485897939.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 13:40:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815023#M321716</guid>
      <dc:creator>Lysegroentblad</dc:creator>
      <dc:date>2022-05-25T13:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two categorical values between two different sites</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815024#M321717</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I am looking to compare if the scores of zero are different between the two sites (p-value for 0, 1 and 2). ...&amp;nbsp;The number of observations in the non-intervention compared to the planted are very different (900 vs. 240), so I assume it is &lt;FONT color="#FF0000"&gt;the frequency&lt;/FONT&gt; I am looking to compare.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I assume you mean: are the &lt;FONT color="#FF0000"&gt;percents &lt;FONT color="#333333"&gt;of&lt;/FONT&gt;&lt;/FONT&gt; zero scores different between the two sites ...&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If so, I'm unclear on another issue. If you limit the data using &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where severity='1';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;as in your code, then you are comparing the 4 times 1 appears next to 'Non-intervention' to the two times 1 appears next to 'Planted', so that's 4 out of 6, which is 66.7% for 'Non-Intervention'. Is that what you want? And then you want to test the 66.7% against the null&amp;nbsp; hypothesis of 50%? Is that what you want?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If no, can you please describe in more detail (using words and math, not in terms of SAS) what test you are trying to do?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 14:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815024#M321717</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-25T14:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two categorical values between two different sites</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815033#M321720</link>
      <description>&lt;P&gt;If I understand your question, you are trying to do a one-way analysis on the frequency of observations for each of the levels Severity=0, 1, and 2. Try this code:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
input Site	$ Severity;
datalines;
Non-intervention	0
Non-intervention	0
Non-intervention	1
Non-intervention	2
Non-intervention	0
Non-intervention	2
Non-intervention	1
Non-intervention	1
Non-intervention	2
Non-intervention	2
Non-intervention	0
Non-intervention	1
Non-intervention	2
Non-intervention	0
Planted 	0
Planted 	1
Planted 	2
Planted 	2
Planted 	0
Planted 	1
Planted 	2
;

proc sort data=Have;  by Severity; run;

proc freq data=Have;
by Severity;
tables Site / chisq plots=none;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 May 2022 15:09:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815033#M321720</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-05-25T15:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two categorical values between two different sites</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815179#M321751</link>
      <description>&lt;P&gt;Yes, I do mean percentages. Because the difference in the size of datasets will give me a significant difference between the frequancy of sites. The number of observations in the non-intervention is approx. 900 while it is 250 in the planted. So I will, as an example, have 300 observations of severity 0 in the non-intervention, but only 50 in the planted, though the percentages are not far apart.&lt;/P&gt;&lt;P&gt;Is is possible to do what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;did (because that works), only with percentages?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 07:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815179#M321751</guid>
      <dc:creator>Lysegroentblad</dc:creator>
      <dc:date>2022-05-26T07:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two categorical values between two different sites</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815189#M321758</link>
      <description>&lt;P&gt;So what do you want to test? You didn't answer that question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to test 300/900 compared to 50/250?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or do you want to test 300/350 compared to 50/350?&lt;/P&gt;</description>
      <pubDate>Thu, 26 May 2022 11:40:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815189#M321758</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-26T11:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two categorical values between two different sites</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815409#M321855</link>
      <description>&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Non-intervention&lt;/TD&gt;&lt;TD&gt;Planted&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;54.48&lt;/TD&gt;&lt;TD&gt;68.33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;26.12&lt;/TD&gt;&lt;TD&gt;16.25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;19.3&lt;/TD&gt;&lt;TD&gt;15.42&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I want to compare these numbers to test if they are significantly different, meaning 1) is 54.48 % significantly different from 68.33 % 2) is 26.12 % significantly different from 16.25 % 3) is 19.3 % significantly different from 15.42 %.&lt;/P&gt;&lt;P&gt;I does not make sense to compare the frequencies that created these percentages since the non-intervention have 900 observations and the Planted have 250 observations. I did that and it says everything is significantly different (&amp;lt;0.0001).&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do may not be possible, though. I am aware of that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maja&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 13:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815409#M321855</guid>
      <dc:creator>Lysegroentblad</dc:creator>
      <dc:date>2022-05-27T13:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two categorical values between two different sites</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815413#M321857</link>
      <description>&lt;P&gt;First, there is a statistical problem here, in that these comparisons are not independent of one another, and so there are really NOT three different independent comparisons.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you perform the overall chi-squared test for your 2x3 table, this will tell you whether or not there is any pattern in the data other than independence of the percents in the table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
     tables site*severity/chisq;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this chi-squared test shows to be not statistically significant, I would stop there and say no difference anywhere. If the Chi-square is statistically significant, then you can certainly do the tests in your table (although I can't think of a quick way to do all three).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can compare the first row (54.48 to 68.33) using this code and then you'd have to repeat and modify the code to do all three.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value sev 0='0' 1,2='Other';
run;
proc freq data=have;
     tables site*severity/chisq;
     format severity sev.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Again, I point out the doing all three of these tests isn't really statistically valid as the tests are not independent of one another.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 13:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815413#M321857</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-05-27T13:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two categorical values between two different sites</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815813#M321986</link>
      <description>Thank you.</description>
      <pubDate>Tue, 31 May 2022 11:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-categorical-values-between-two-different/m-p/815813#M321986</guid>
      <dc:creator>Lysegroentblad</dc:creator>
      <dc:date>2022-05-31T11:22:29Z</dc:date>
    </item>
  </channel>
</rss>

