<?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: paired categorical data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750200#M235911</link>
    <description>&lt;P&gt;Wouldn't a simple PROC FREQ show you an imbalance in these values?&lt;/P&gt;</description>
    <pubDate>Thu, 24 Jun 2021 13:47:25 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-06-24T13:47:25Z</dc:date>
    <item>
      <title>paired categorical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750145#M235889</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;BR /&gt;I am working on a dataset, where I have to test if there is a significant difference in categorical variables from one timepoint to another in the same person.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My variables contains 2 or 3 categories (0,1,2).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which test will be suitable to use - especially for the 3 category variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 10:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750145#M235889</guid>
      <dc:creator>lone0708</dc:creator>
      <dc:date>2021-06-24T10:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: paired categorical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750148#M235892</link>
      <description>&lt;P&gt;With categorical values, any difference is significant. So I would simply count the distinct values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input person $ cat_var;
datalines;
A 0
A 1
B 0
B 0
;

proc sql;
create table want as
  select
    person
  from have
  group by person
  having count(distinct cat_var) &amp;gt; 1
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Jun 2021 11:04:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750148#M235892</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-24T11:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: paired categorical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750151#M235893</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338918"&gt;@lone0708&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&amp;nbsp;&lt;BR /&gt;I am working on a dataset, where I have to test if there is a significant difference in categorical variables ...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Significant difference between some statistic for the categorical variables (if so, what statistic?) or significant difference between the categorical variables themselves (if so, please explain in a lot more detail)&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 11:43:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750151#M235893</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-24T11:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: paired categorical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750174#M235897</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I am searching to test significant difference between the categorical variables themselves. My dataset looks like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Patient Time1 Time2. &amp;nbsp; &amp;nbsp;Postion_time1. &amp;nbsp;position_time2 &amp;nbsp;Light_time1 &amp;nbsp;light_time2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;A. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13:14. &amp;nbsp;14:00. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;B. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12:00. &amp;nbsp;12:15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;C. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12:13. &amp;nbsp;14:45 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to test, if position and light are generally the same at the two timepoints or&lt;/SPAN&gt;&lt;SPAN&gt; is for example&amp;nbsp;position 3 overrepresented at time 1. I hope it makes sense&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 12:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750174#M235897</guid>
      <dc:creator>lone0708</dc:creator>
      <dc:date>2021-06-24T12:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: paired categorical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750192#M235907</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I am searching to test significant difference between the categorical variables themselves.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;I am very confused. As far as I know, this can't be done. It is not a statistical concept to test categorical variables themselves. (Or in the trivial sense, they are always different). The only statistical concept is to test statistics for each categorical variable to see if the statistics are different in the different categories, and you seem to be saying that's not what you want.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the data set you show, describe the steps (in words) to show how you would answer the question.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 13:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750192#M235907</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-24T13:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: paired categorical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750200#M235911</link>
      <description>&lt;P&gt;Wouldn't a simple PROC FREQ show you an imbalance in these values?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 13:47:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750200#M235911</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-24T13:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: paired categorical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750223#M235925</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338918"&gt;@lone0708&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean a test for marginal homogeneity (i.e., whether the distribution of "position" has changed from time 1 to time 2, and similar for "light")?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so, the test "&lt;SPAN&gt;equivalent to Bhapkar’s test" presented in&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_catmod_examples08.htm" target="_blank" rel="noopener"&gt;Example 35.7 Repeated Measures, 4 Response Levels, 1 Population&lt;/A&gt; of the PROC CATMOD documentation might be appropriate, especially in the case of more than two categories. (See also&amp;nbsp;&lt;A href="https://support.sas.com/kb/39/243.html" target="_self"&gt;https://support.sas.com/kb/39/243.html&lt;/A&gt;.) For dichotomous variables (e.g., if "light" is either 0 or 1) McNemar's test should be applicable, see the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/statug/statug_freq_details78.htm" target="_blank" rel="noopener"&gt;Tests and Measures of Agreement&lt;/A&gt; available in PROC FREQ.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create sample data for demonstration */

data have;
call streaminit(27182818);
do patient=1 to 250;
  time1=round(rand('integer','8:00't,'14:00't),60);
  time2=time1+round(rand('integer','0:15't,'6:00't),60);
  position_time1=rand('table',0.2, 0.3, 0.4)-1;
  position_time2=rand('table',0.25,0.35,0.25)-1;
  light_time1=rand('bern',0.6);
  light_time2=rand('bern',0.5);
  output;
end;
format time: time5.;
run;

/* Perform tests for marginal homogeneity */

proc catmod data=have namelen=29;
response marginals;
model position_time1*position_time2=_response_ / freq design;
repeated time 2;
quit;

proc freq data=have;
tables light_time1*light_time2 / agree;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Edit: Note that the difference between time 1 and time 2, be it 15 minutes or 6 hours, is disregarded in these tests.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 14:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750223#M235925</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-06-24T14:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: paired categorical data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750237#M235935</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338918"&gt;@lone0708&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;I am searching to test significant difference between the categorical variables themselves. My dataset looks like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Patient Time1 Time2. &amp;nbsp; &amp;nbsp;Postion_time1. &amp;nbsp;position_time2 &amp;nbsp;Light_time1 &amp;nbsp;light_time2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;A. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;13:14. &amp;nbsp;14:00. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;B. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12:00. &amp;nbsp;12:15 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;C. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12:13. &amp;nbsp;14:45 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want to test, if position and light are generally the same at the two timepoints or&lt;/SPAN&gt;&lt;SPAN&gt; is for example&amp;nbsp;position 3 overrepresented at time 1. I hope it makes sense&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Proc freq with the EXPECTED option on the tables statement sounds like what you might be looking for.&lt;/P&gt;
&lt;P&gt;Here's a brief example creating a data set with two variables to "compare". The Rand ('integer', n) function creates random integers in the 1 to n interval.&lt;/P&gt;
&lt;P&gt;You can se the counts of the intersections of the values and compare with an "expected" value based on the distribution.&lt;/P&gt;
&lt;PRE&gt;data example;
   /*should produce relatively similar distributions*/
   do i=1 to 50;
      x= rand('integer',3);
      y= rand('integer',3);
      output;
   end;
   /* now add some to bias a variable, y won't have any 3*/
   do i=51 to 100;
      x= rand('integer',3);
      y= rand('integer',2);
      output;
   end;
run;

proc freq data=example;
   tables x*y /expected chisq;
run;
&lt;/PRE&gt;
&lt;P&gt;Throw in a Chi-square test and you have a statistic that tests similarity of distribution.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jun 2021 15:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/paired-categorical-data/m-p/750237#M235935</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-06-24T15:18:30Z</dc:date>
    </item>
  </channel>
</rss>

