<?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 do I prepare this data for a chisq test in SAS? in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775430#M37959</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/370041"&gt;@bazingarollcall&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;You're right, this is a proc means output. I've output this table to it's own dataset called b2_table. I am using &lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;this same dataset&lt;/STRONG&gt;&lt;/FONT&gt; for the proc freq table.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Assuming, 'this same dataset' is b2_table, then you need to add a WEIGHT N statement to your PROC FREQ or use the raw data instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=b2_table;
table Adult_Survey_Results*gender / chisq;&amp;nbsp;
weight N;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 20 Oct 2021 15:47:29 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-10-20T15:47:29Z</dc:date>
    <item>
      <title>How do I prepare this data for a chisq test in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775419#M37956</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN style="font-family: inherit;"&gt;Hello,&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN style="font-family: inherit;"&gt;I have the following dataset:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;Adult_Survey_Results agec MEAN N Frequency Percent Cumulative &lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1.Access&lt;/TD&gt;&lt;TD&gt;Adult&lt;/TD&gt;&lt;TD&gt;1.8631301731&lt;/TD&gt;&lt;TD&gt;2215&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4.17&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1.Access&lt;/TD&gt;&lt;TD&gt;Older Adult&lt;/TD&gt;&lt;TD&gt;2.0261437908&lt;/TD&gt;&lt;TD&gt;306&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4.17&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1.Access&lt;/TD&gt;&lt;TD&gt;Young Adult&lt;/TD&gt;&lt;TD&gt;1.8697916667&lt;/TD&gt;&lt;TD&gt;128&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4.17&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2.Quality and Appropriateness&lt;/TD&gt;&lt;TD&gt;Adult&lt;/TD&gt;&lt;TD&gt;1.9121645347&lt;/TD&gt;&lt;TD&gt;2215&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4.17&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2.Quality and Appropriateness&lt;/TD&gt;&lt;TD&gt;Older Adult&lt;/TD&gt;&lt;TD&gt;2.107480029&lt;/TD&gt;&lt;TD&gt;306&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4.17&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2.Quality and Appropriateness&lt;/TD&gt;&lt;TD&gt;Young Adult&lt;/TD&gt;&lt;TD&gt;1.8784722222&lt;/TD&gt;&lt;TD&gt;128&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;4.17&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;P&gt;Where agec is broken into 3 categories "Young Adult, Adult, and Older Adult," and Adult_Survey_Results is broken into 2 domains "Access, and Quality and Appropriateness."&lt;/P&gt;&lt;P&gt;I want to answer the question "What is the amount of interaction between the age groups and the survey domain?" Essentially, does age group affect the client's answer to the survey?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried the simple&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc freq data=b2_table;&lt;/P&gt;&lt;P&gt;table Adult_Survey_Results*gender / chisq; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it prints results based on the Adult_Survey_Results frequency, where I think I need this based on Adult_Survey_Results N instead.&lt;/P&gt;&lt;P&gt;How would you go about this?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 20 Oct 2021 14:59:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775419#M37956</guid>
      <dc:creator>bazingarollcall</dc:creator>
      <dc:date>2021-10-20T14:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I prepare this data for a chisq test in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775422#M37957</link>
      <description>That looks like an output from PROC MEANs. What does your raw data look like? Which data set are you using in PROC FREQ - the output from PROC MEANS or the raw data?</description>
      <pubDate>Wed, 20 Oct 2021 15:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775422#M37957</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-20T15:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I prepare this data for a chisq test in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775429#M37958</link>
      <description>You're right, this is a proc means output. I've output this table to it's own dataset called b2_table. I am using this same dataset for the proc freq table.</description>
      <pubDate>Wed, 20 Oct 2021 15:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775429#M37958</guid>
      <dc:creator>bazingarollcall</dc:creator>
      <dc:date>2021-10-20T15:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I prepare this data for a chisq test in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775430#M37959</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/370041"&gt;@bazingarollcall&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;You're right, this is a proc means output. I've output this table to it's own dataset called b2_table. I am using &lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;this same dataset&lt;/STRONG&gt;&lt;/FONT&gt; for the proc freq table.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Assuming, 'this same dataset' is b2_table, then you need to add a WEIGHT N statement to your PROC FREQ or use the raw data instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=b2_table;
table Adult_Survey_Results*gender / chisq;&amp;nbsp;
weight N;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Oct 2021 15:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775430#M37959</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-20T15:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I prepare this data for a chisq test in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775433#M37961</link>
      <description>It appears that you would use the data set that you used for INPUT to Proc Means as the data for Proc freq.&lt;BR /&gt;The tables statement would look like:&lt;BR /&gt;Tables Adult_Survey_Results * agec / chisq;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Oct 2021 15:55:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775433#M37961</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-20T15:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: How do I prepare this data for a chisq test in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775444#M37962</link>
      <description>&lt;P&gt;I think my question needs more back-up information.&lt;BR /&gt;&lt;BR /&gt;The code I used to create the b2_stats database is as follows:&lt;BR /&gt;&lt;BR /&gt;proc summary data=formatting mean std lclm uclm n noprint;&lt;BR /&gt;class agec gender;&lt;BR /&gt;var mean_func ;&lt;BR /&gt;var mean_sc ;&lt;BR /&gt;var mean_acc ;&lt;BR /&gt;var mean_qa ;&lt;BR /&gt;var mean_out ;&lt;BR /&gt;var mean_part ;&lt;BR /&gt;var mean_sat ;&lt;BR /&gt;var mean_qol;&lt;BR /&gt;output out=b1_b2_stats;&lt;BR /&gt;&lt;BR /&gt;output out=mean1 mean=;&lt;BR /&gt;*output out=uclm1 uclm=;&lt;BR /&gt;*output out=lclm1 lclm=;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data b1_b2_stats2;&lt;BR /&gt;format _STAT_ $30.;&lt;BR /&gt;set b1_b2_stats&lt;BR /&gt;mean1(in=in2) ;&lt;BR /&gt;if in2 then _STAT_ = 'Mean';&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sort data=b1_b2_stats2&lt;BR /&gt;out=b1_stats;&lt;BR /&gt;by agec _TYPE_ _stat_;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc transpose data=b1_stats out=b1_han;&lt;BR /&gt;by agec _TYPE_;&lt;BR /&gt;id _stat_;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data b1_table /*(keep=agec _TYPE_ _STAT_ Adult_Survey_Results Responses Number_Positive Percent_Positive Confidence_Interval)*/;&lt;BR /&gt;format Adult_Survey_Results $40.;&lt;BR /&gt;&lt;BR /&gt;set b1_han;&lt;BR /&gt;if _NAME_ = 'mean_acc' then Adult_Survey_Results= '1.Access';&lt;BR /&gt;else if _NAME_= 'mean_qa' then Adult_Survey_Results= '2.Quality and Appropriateness';&lt;BR /&gt;else if _NAME_= 'mean_func' then Adult_Survey_Results= '7.Functioning';&lt;BR /&gt;else if _NAME_= 'mean_sat' then Adult_Survey_Results= '5.General Satisfaction';&lt;BR /&gt;else if _NAME_= 'mean_out' then Adult_Survey_Results= '3.Outcomes';&lt;BR /&gt;else if _NAME_= 'mean_sc' then Adult_Survey_Results= '6.Social Connectedness';&lt;BR /&gt;else if _NAME_= 'mean_part' then Adult_Survey_Results= '4.Participation In Treatment Planning';&lt;BR /&gt;else if _NAME_= 'mean_qol' then Adult_Survey_Results= '8.Quality of Life Assessment';&lt;BR /&gt;else if _NAME_='_FREQ_' and agec='Adult' then Adult_Survey_Results='Adult Overall';&lt;BR /&gt;else if _NAME_='_FREQ_' and agec='Older Adult' then Adult_Survey_Results='O.A. Overall';&lt;BR /&gt;else if _NAME_='_FREQ_' and agec='Young Adult' then Adult_Survey_Results='Y.A. Overall';&lt;BR /&gt;&lt;BR /&gt;Responses=N;&lt;BR /&gt;STD1=STD;&lt;BR /&gt;MEAN1=MEAN*100;&lt;BR /&gt;*P951=P95;&lt;BR /&gt;*LCLM1=round(LCLM*N);&lt;BR /&gt;*UCLM1=round(UCLM*N);&lt;BR /&gt;*Percent_Positive=(Number_Positive /Responses);&lt;BR /&gt;*Confidence_Interval=cats(trim(LCLM1),'-',trim(UCLM1));&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;The chisq command produced the attached table, which is very close to what I need but still not quite right. The weight statement pulled from N, but the program summed the totals of all the rows (which totaled the total of the entire dataset, 2757), and added all of those together, which is incorrect. I need the total to remain the same of the entire dataset (2757).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Proc report of b2_table is also attached.&lt;BR /&gt;&lt;BR /&gt;proc freq data=b2_table;&lt;BR /&gt;table Adult_Survey_Results*agec / chisq;&lt;BR /&gt;weight N;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;I'm thinking that I need to somehow "pluck" the N of each Adult_Survey_Results , along with the agec categories and their frequencies, into another table and use this for chisq. Would this work?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 16:47:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775444#M37962</guid>
      <dc:creator>bazingarollcall</dc:creator>
      <dc:date>2021-10-20T16:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: How do I prepare this data for a chisq test in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775460#M37964</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/370041"&gt;@bazingarollcall&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;The chisq command produced the attached table, which is very close to what I need but still not quite right. The weight statement pulled from N, but the program summed the totals of all the rows (which totaled the total of the entire dataset, 2757), and added all of those together, which is incorrect. I need the total to remain the same of the entire dataset (2757).&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at your output data sets from Proc Summary such as b1_b2_stats. You will see that there is a variable named _type_ that indicates the combinations of the Class variables. Since you have two variables you will have 4 levels of _type_, 0, 1, 2 and 3. The 0, 1 and 2 will be: 0 is overall records, 1 each level of one of the class variables and 2 is each level of the other class variables. It is very likely that want to use the &lt;STRONG&gt;NWAY&lt;/STRONG&gt; option on Proc summary to only include the _type_ = 3 values, which are the actual combinations of the levels for &lt;STRONG&gt;both&lt;/STRONG&gt; class variables.&lt;/P&gt;
&lt;P&gt;Otherwise N is going to be about 4 times the number of original records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am very confused about doing Chisq with the means of multiple variables as categories though. What is the exact question this chisq is supposed to answer? "Amount of interaction" is not what a chisq tests for. It checks for similarity of distribution of values between two variables. Or in other words, given the counts are they close to the expected counts if the row/column were distributed the same. More of a yes/no than a "how much" test.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 17:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775460#M37964</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-20T17:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I prepare this data for a chisq test in SAS?</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775639#M37981</link>
      <description>I thought about your response overnight and can't thank you enough for it.&lt;BR /&gt;&lt;BR /&gt;I no longer think chisq is appropriate in this situation; I will need something like T-Test to determine if there is significant difference between the means of the 3 groups of agec.</description>
      <pubDate>Thu, 21 Oct 2021 13:12:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-do-I-prepare-this-data-for-a-chisq-test-in-SAS/m-p/775639#M37981</guid>
      <dc:creator>bazingarollcall</dc:creator>
      <dc:date>2021-10-21T13:12:34Z</dc:date>
    </item>
  </channel>
</rss>

