<?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: Two questions about ChiSquare: get STDRES into the column and colorize the results in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Two-questions-about-ChiSquare-get-STDRES-into-the-column-and/m-p/884337#M349359</link>
    <description>&lt;P&gt;A quick and easy way is to just save the CROSSLIST table and then plot it as a heat map in PROC SGPLOT. For example&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=mydata;
table row*col / chisq crosslist(stdres);
ods output crosslist=clist;
run;
proc sgplot data=clist;
heatmapparm y=col x=row colorresponse=stdresidual;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 11 Jul 2023 14:25:47 GMT</pubDate>
    <dc:creator>StatDave</dc:creator>
    <dc:date>2023-07-11T14:25:47Z</dc:date>
    <item>
      <title>Two questions about ChiSquare: get STDRES into the column and colorize the results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-questions-about-ChiSquare-get-STDRES-into-the-column-and/m-p/884288#M349344</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I calculated a chi²-test by running proc freq with this code: &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sashelp.cars;
table type*Origin /cellchi2 chisq expected deviation STDRES;
where type &amp;lt;&amp;gt;"Hybrid" and type&amp;lt;&amp;gt;"Truck";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...and got this result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Konkordanz_0-1689059818462.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85710iA09527330F32AE2F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Konkordanz_0-1689059818462.png" alt="Konkordanz_0-1689059818462.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result shows: The differences are significant.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Question 1:&lt;/STRONG&gt; Now I want to know, where are the biggest/lowest differences between the expected and the observed values. There it would be helpful, to colorize all the values of the row "deviation". For example like in Excel "conditional formatting". For example, I want the numbers to become greener the larger the number. Is there a option for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Question 2: &lt;/STRONG&gt;Because I want to know, which cells are the reason for this chi²-result, Ive choosen the output incl "STDRES". With these standardized residuals, I want to find out which cells indicate particularly striking differences. But I cant find them in my result. Ive red, that I have to use "crosslist" like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc freq data=sashelp.cars;
table type*Origin /crosslist cellchi2 chisq expected deviation  STDRES;
where type &amp;lt;&amp;gt;"Hybrid" and type&amp;lt;&amp;gt;"Truck";
run;
&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Konkordanz_1-1689060605731.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85711i59597B437765C38F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Konkordanz_1-1689060605731.png" alt="Konkordanz_1-1689060605731.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The design is much different from the other I want. Therefore my &lt;STRONG&gt;question&lt;/STRONG&gt;: How can I display the STDRES-Values as&amp;nbsp; additional Row within the first output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Thank you for helping again!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 07:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-questions-about-ChiSquare-get-STDRES-into-the-column-and/m-p/884288#M349344</guid>
      <dc:creator>Konkordanz</dc:creator>
      <dc:date>2023-07-11T07:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Two questions about ChiSquare: get STDRES into the column and colorize the results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-questions-about-ChiSquare-get-STDRES-into-the-column-and/m-p/884323#M349354</link>
      <description>&lt;P&gt;Better post it at Stat Forum:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Statistical-Procedures/bd-p/statistical_procedures" target="_blank"&gt;https://communities.sas.com/t5/Statistical-Procedures/bd-p/statistical_procedures &lt;/A&gt;&lt;/P&gt;
&lt;P&gt;and calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633"&gt;@StatDave&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 12:06:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-questions-about-ChiSquare-get-STDRES-into-the-column-and/m-p/884323#M349354</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-07-11T12:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Two questions about ChiSquare: get STDRES into the column and colorize the results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-questions-about-ChiSquare-get-STDRES-into-the-column-and/m-p/884337#M349359</link>
      <description>&lt;P&gt;A quick and easy way is to just save the CROSSLIST table and then plot it as a heat map in PROC SGPLOT. For example&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=mydata;
table row*col / chisq crosslist(stdres);
ods output crosslist=clist;
run;
proc sgplot data=clist;
heatmapparm y=col x=row colorresponse=stdresidual;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2023 14:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-questions-about-ChiSquare-get-STDRES-into-the-column-and/m-p/884337#M349359</guid>
      <dc:creator>StatDave</dc:creator>
      <dc:date>2023-07-11T14:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Two questions about ChiSquare: get STDRES into the column and colorize the results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Two-questions-about-ChiSquare-get-STDRES-into-the-column-and/m-p/884372#M349385</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/388612"&gt;@Konkordanz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I calculated a chi²-test by running proc freq with this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sashelp.cars;
table type*Origin /cellchi2 chisq expected deviation STDRES;
where type &amp;lt;&amp;gt;"Hybrid" and type&amp;lt;&amp;gt;"Truck";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;...and got this result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Konkordanz_0-1689059818462.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85710iA09527330F32AE2F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Konkordanz_0-1689059818462.png" alt="Konkordanz_0-1689059818462.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result shows: The differences are significant.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Question 1:&lt;/STRONG&gt; Now I want to know, where are the biggest/lowest differences between the expected and the observed values. There it would be helpful, to colorize all the values of the row "deviation". For example like in Excel "conditional formatting". For example, I want the numbers to become greener the larger the number. Is there a option for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Question 2: &lt;/STRONG&gt;Because I want to know, which cells are the reason for this chi²-result, Ive choosen the output incl "STDRES". With these standardized residuals, I want to find out which cells indicate particularly striking differences. But I cant find them in my result. Ive red, that I have to use "crosslist" like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc freq data=sashelp.cars;
table type*Origin /crosslist cellchi2 chisq expected deviation  STDRES;
where type &amp;lt;&amp;gt;"Hybrid" and type&amp;lt;&amp;gt;"Truck";
run;
&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Konkordanz_1-1689060605731.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85711i59597B437765C38F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Konkordanz_1-1689060605731.png" alt="Konkordanz_1-1689060605731.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The design is much different from the other I want. Therefore my &lt;STRONG&gt;question&lt;/STRONG&gt;: &lt;FONT color="#FF00FF"&gt;&lt;STRONG&gt;How can I display the STDRES-Values as&amp;nbsp; additional Row within the first output?&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Thank you for helping again!&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Generic response to "how to combine output": Use the ODS OUTPUT option for the results tables to get the different tables present in the results as data sets. Then combine them and use a different reporting procedure, Print, Report or Tabulate to display the desired results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The documentation for Proc Freq (and practically every procedure that generates ODS output) will have the ODS Table names in the details section of the online help.&lt;/P&gt;
&lt;P&gt;HOW to combine them depends on what the desired appearance will be. Also, be aware that the content of those data sets will likely differ from the way displayed in results to meet data set requirements such as single variable of given name.&lt;/P&gt;
&lt;P&gt;Your code generates this log:&lt;/P&gt;
&lt;PRE&gt;23   proc freq data=sashelp.cars;
24   table type*Origin /cellchi2 chisq expected deviation STDRES;
25   where type &amp;lt;&amp;gt;"Hybrid" and type&amp;lt;&amp;gt;"Truck";
NOTE: The "&amp;lt;&amp;gt;" operator is interpreted as "not equals".
26   run;

NOTE: Writing HTML Body file: sashtml.htm
WARNING: The STDRES option is available only with the CROSSLIST option.

&lt;/PRE&gt;
&lt;P&gt;Which means you cannot get what you are requesting unless you add the CROSSLIST option to the table statement.&lt;/P&gt;
&lt;P&gt;If you want to find the largest, smallest or compare any of the results in the the results the ODS OUTPUT created data sets is likely what you want to use to search in as well.&lt;/P&gt;
&lt;PRE&gt;proc freq data=sashelp.cars;
ods output crosslist =mycrosslistdata
           chisq     =mychisqdata
;
table type*Origin /crosslist cellchi2 chisq expected deviation STDRES;
where type &amp;lt;&amp;gt;"Hybrid" and type&amp;lt;&amp;gt;"Truck";
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Caution: use of the &amp;lt;&amp;gt; as a comparison has different meanings in some places where it is a MAX operator. So you may want to use NE for 'not equal'. To save some typing you might consider:&lt;/P&gt;
&lt;PRE&gt;where type not in ('Hybrid' 'Truck');&lt;/PRE&gt;</description>
      <pubDate>Tue, 11 Jul 2023 17:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Two-questions-about-ChiSquare-get-STDRES-into-the-column-and/m-p/884372#M349385</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-07-11T17:07:20Z</dc:date>
    </item>
  </channel>
</rss>

