<?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: computing means of a categorical variable in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482615#M71678</link>
    <description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#339966" size="6"&gt;Provide a worked small example of what you want. A small input set and the desired result.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;Otherwise you are talking around a bunch of next to nonsense.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;IF you have an order to your categorical variable, which you have not stated or shown in any way, the concept of "median" as the middle value&amp;nbsp;might apply. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;If I have values of a, b, c, a, c, d, p, d, q where the "order" is normal alphabetical order then the data could be reordered to&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;a,a,b,c,c,d,d,p,q. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;Of the 9 elements shown then the "median" would be the second c as 4 values come before and after.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;If you have an even number such as 18 elements, then the 9th and 10th would have to be considered and tie breaking becomes an issue if both values are different. If the 9th were "m" and the 10th were "s" what value to pick as the middle might be more problematic.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;And your apparent quote helps not as it appears to be a response to something without context.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jul 2018 21:15:44 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-07-30T21:15:44Z</dc:date>
    <item>
      <title>computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482589#M71668</link>
      <description>&lt;P&gt;I am still a novice ... so easily confused! I was told to compute the means for all explanatory variables (SAS 9.4). But, the variables are all categorical variables. For example, I tried to get the means for the two health reasons (physical and mental health), coded as 1 and 2. I used the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;proc means data=onespell mean, std;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class=healthreason;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var=spell_length;&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;This is not giving me what I want. Apparently, because the data is stacked, it includes all observations on a person. I just want a one-person file. My co-investigator responded thus&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;"Are you looking for the average for persons in your sample?&amp;nbsp; I am not sure what data is going into the procedure. It appears that the data you are inputting is all the observations on the first spell, so many of those people have multiple observations because they have many months in that spell. If that is the case, then the average will be biased by people who have longer first spells and more observation months. Also, the sample count for the mean will not be people but observation months (many more observation months than people). Lastly, I though you coded health reason as a categorical variable with three categories (0, 1, and 2 or something like that). So that would mean that you are better to look at the proportion of the sample in each category rather an mean value. An average of 0, 1, and 2 values would not give you a meaningful mean value."&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Serving only to confuse me more.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Can someone help me unravel this?&lt;/DIV&gt;</description>
      <pubDate>Mon, 30 Jul 2018 19:54:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482589#M71668</guid>
      <dc:creator>pammers</dc:creator>
      <dc:date>2018-07-30T19:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482591#M71669</link>
      <description>&lt;P&gt;Since you want to compute a mean of a categorical variable, would you please explain in your own words what that means? Don't even use SAS or other computer language in your explanation, just try to articulate what the mean of a categorical variable really means.&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 20:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482591#M71669</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-30T20:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482594#M71670</link>
      <description>&lt;P&gt;To be clear, I don't see the point in computing means ... However, since I must ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The means is an average of all counts within an observation. So let's take health reason. I want to know how many people in my sample have physical illness vs. those with mental illness. A proc freq provides a descriptive table and tells me that (making up a number here) 122, 000 have PI and 132, 000 have MI; the percentage is provided in a SAS output so I know my sample consists of 46% (again only for example sake). However, I need to also do this for the regression model in which I have 10 explanatory variables. The means and STD do not get automatically generated in a proc gen. How do I get the same information with the model as I did with the descriptive stat?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 20:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482594#M71670</guid>
      <dc:creator>pammers</dc:creator>
      <dc:date>2018-07-30T20:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482598#M71671</link>
      <description>&lt;P&gt;Okay, good, we agree that it doesn't make sense to compute a mean of a categorical variable. The only descriptive statistic that we can compute is the percent in each category.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;However, I need to also do this for the regression model in which I have 10 explanatory variables.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I don't know what this means, or why you need to do this for a regression model.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The means and STD do not get automatically generated in a proc gen. How do I get the same information with the model as I did with the descriptive stat?&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do you mean proc reg? Why do you need means and standard deviations here, if we have already established that these can't be computed for categorical variables. Explain.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 20:27:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482598#M71671</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-30T20:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482601#M71672</link>
      <description>&lt;P&gt;Oh good. So I am not a complete idiot! This is the answer I received when I asked that very question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Generally, for explanatory variable descriptives one would do means and standard deviations for continuous variables. &lt;STRONG&gt;For categorical variables it is best to present the proportion of the sample in each category.&lt;/STRONG&gt; You will need to also make a distinction between a person, versus observation months on a person within a spell, versus multiple spells of a person in the program. The data is currently structured so that observation months are stacked. If you simple do a proc mean (or other stat) for a variable, you will get a mean value for all the observations month across multiple spells within and across persons. To have a person file, you need to keep only one observation per person and then do a mean (or other stat). To have a spell file, you need to keep only one observation per spell and then do mean (or other stat). What observation to keep for a person or a spell is also critical. For example, only the last observation in a spell has info about exit"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again. I am using the proc gen procedure with a clog-log model.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 20:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482601#M71672</guid>
      <dc:creator>pammers</dc:creator>
      <dc:date>2018-07-30T20:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482602#M71673</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154614"&gt;@pammers&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;To be clear, I don't see the point in computing means ... However, since I must ...&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You would never compute the mean of a categorical variable so don't bother.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you recoded them as 0/1 and then calculate the mean you'll get the EXACT same information as the percentage. Check it. If they're off you likely haven't accounted for missing the same in both procedures.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 20:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482602#M71673</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-30T20:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482604#M71674</link>
      <description>Sorry, I don't understand what you by "you likely haven't accounted for missing the same in both procedures." At any rate, what code do i use to get this?</description>
      <pubDate>Mon, 30 Jul 2018 20:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482604#M71674</guid>
      <dc:creator>pammers</dc:creator>
      <dc:date>2018-07-30T20:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482615#M71678</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#339966" size="6"&gt;Provide a worked small example of what you want. A small input set and the desired result.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;Otherwise you are talking around a bunch of next to nonsense.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;IF you have an order to your categorical variable, which you have not stated or shown in any way, the concept of "median" as the middle value&amp;nbsp;might apply. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;If I have values of a, b, c, a, c, d, p, d, q where the "order" is normal alphabetical order then the data could be reordered to&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;a,a,b,c,c,d,d,p,q. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;Of the 9 elements shown then the "median" would be the second c as 4 values come before and after.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;If you have an even number such as 18 elements, then the 9th and 10th would have to be considered and tie breaking becomes an issue if both values are different. If the 9th were "m" and the 10th were "s" what value to pick as the middle might be more problematic.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" size="3"&gt;And your apparent quote helps not as it appears to be a response to something without context.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 21:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482615#M71678</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-30T21:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482624#M71679</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154614"&gt;@pammers&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Generally, for explanatory variable descriptives one would do means and standard deviations for continuous variables. &lt;STRONG&gt;For categorical variables it is best to present the proportion of the sample in each category.&lt;/STRONG&gt; You will need to also make a distinction between a person, versus observation months on a person within a spell, versus multiple spells of a person in the program. The data is currently structured so that observation months are stacked. If you simple do a proc mean (or other stat) for a variable, you will get a mean value for all the observations month across multiple spells within and across persons. To have a person file, you need to keep only one observation per person and then do a mean (or other stat). To have a spell file, you need to keep only one observation per spell and then do mean (or other stat). What observation to keep for a person or a spell is also critical. For example, only the last observation in a spell has info about exit"&lt;/P&gt;
&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Without knowing your data, a lot of the above is gibberish. I thought only witches and warlocks had multiple spells. But in general, I have not come across the noun "spell" in any particular field of endeavor other than writing and casting spells over people. Most of the above quote from your professor (?) is meaningless to me in the statistical context of fitting a model.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2018 22:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482624#M71679</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-30T22:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482663#M71681</link>
      <description>Your data has repeated measures. So you need to account for that as well. You cannot do a PROC MEANS or FREQ Without accounting for it otherwise you’re counting the duplicates.</description>
      <pubDate>Tue, 31 Jul 2018 00:56:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482663#M71681</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-31T00:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: computing means of a categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482774#M71682</link>
      <description>HI Paige,&lt;BR /&gt;&lt;BR /&gt;Thank you. I realize that but not sure how to do that. I used&lt;BR /&gt;by first.X (x being my variable). Anyway exhausted last night so maybe I will figure it out today. I used proc genmod to generate the model. Sorry, I confused you on that. So to get the means of each variable I have been using this code:&lt;BR /&gt;&lt;BR /&gt;Proc means Data=onespell (the constructed variable)&lt;BR /&gt;Class X&lt;BR /&gt;Var (all my list of dependent variables)&lt;BR /&gt;&lt;BR /&gt;Thank you for your patience and kindness.</description>
      <pubDate>Tue, 31 Jul 2018 12:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/computing-means-of-a-categorical-variable/m-p/482774#M71682</guid>
      <dc:creator>pammers</dc:creator>
      <dc:date>2018-07-31T12:36:29Z</dc:date>
    </item>
  </channel>
</rss>

