<?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: Is it possible to get quartiles from a categorical variable with 100 levels? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801184#M315292</link>
    <description>&lt;P&gt;Yes - we are creating a score based on multiple health behaviors that will be parsed into quintiles, so the goal is to parse this variable into quartiles and then have the last category of individuals who do not smoke be the last quintile.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Mar 2022 20:31:12 GMT</pubDate>
    <dc:creator>Corinthian94</dc:creator>
    <dc:date>2022-03-09T20:31:12Z</dc:date>
    <item>
      <title>Is it possible to get quartiles from a categorical variable with 100 levels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801170#M315285</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a dataset with a variable measuring the amount of cigarettes individuals had per week at baseline. I did not help create this dataset so I'm not sure why it is coded as categorical rather than continuous given the amount of levels it has, but I would like to get quartiles from this group. As I understand it, proc rank or univariate will not work because it is a categorical variable.&lt;/P&gt;&lt;P&gt;The other caveat to this is that when I try to calculate it by hand and manually create a categorical variable, there are levels that contain more than observations than one quartile alone would contain. So if I were to try and do it by the values that are available, I would end up with uneven quartiles. Is there another way to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 19:38:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801170#M315285</guid>
      <dc:creator>Corinthian94</dc:creator>
      <dc:date>2022-03-09T19:38:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get quartiles from a categorical variable with 100 levels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801178#M315288</link>
      <description>Is there some reason you can't use the original variable with the number of cigarettes?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Mar 2022 20:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801178#M315288</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-03-09T20:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get quartiles from a categorical variable with 100 levels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801184#M315292</link>
      <description>&lt;P&gt;Yes - we are creating a score based on multiple health behaviors that will be parsed into quintiles, so the goal is to parse this variable into quartiles and then have the last category of individuals who do not smoke be the last quintile.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 20:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801184#M315292</guid>
      <dc:creator>Corinthian94</dc:creator>
      <dc:date>2022-03-09T20:31:12Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get quartiles from a categorical variable with 100 levels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801185#M315293</link>
      <description>Still not sure why you can't run PROC RANK on the original variable? Then you would use a second data step to add your 5th category. I hesitate to call it a quintile as the number may not reflect 20% of the data. &lt;BR /&gt;&lt;BR /&gt;Or do you mean the variable is character type, not numeric which is why PROC RANK won't work?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Mar 2022 20:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801185#M315293</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-03-09T20:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get quartiles from a categorical variable with 100 levels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801186#M315294</link>
      <description>&lt;P&gt;Ye exactly! The original variable is character which is why proc rank won't work, and I'm not sure how to create the quartiles otherwise.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 20:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801186#M315294</guid>
      <dc:creator>Corinthian94</dc:creator>
      <dc:date>2022-03-09T20:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get quartiles from a categorical variable with 100 levels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801187#M315295</link>
      <description>&lt;P&gt;Convert it to numeric in a data step and then use proc rank.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data numeric;
set have;

numeric_var = input(oldVar, 8.);

run;

proc rank data=numeric out=want_ranks groups=4;
var numeric_var;
ranks ranked_var;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Mar 2022 20:50:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801187#M315295</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-03-09T20:50:18Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get quartiles from a categorical variable with 100 levels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801188#M315296</link>
      <description>A categorical variable is role of a variable and not something that SAS actually defines. It's more about how the variable is used. &lt;BR /&gt;There are variable types, SAS has two numeric and character. &lt;BR /&gt;There are variable formats, those control how a variable is displayed. &lt;BR /&gt;&lt;BR /&gt;A categorical variable can be numeric or character. &lt;BR /&gt;A variable that requires numerical analysis, ie means, standard deviation etc must be numeric. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Mar 2022 20:52:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801188#M315296</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-03-09T20:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get quartiles from a categorical variable with 100 levels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801195#M315297</link>
      <description>&lt;P&gt;Quartiles, or other percentiles, are order statistics. Which means you must be able to place them in some order such that the "first" is the "lowest value" and so. So for percentiles you have to assign that order value to a numeric variable to do percentiles.&lt;/P&gt;
&lt;P&gt;Does your categorical variable have a natural order, such as "first" "second" "third", so that low to high is obvious? Then that step should be relatively easy.&lt;/P&gt;
&lt;P&gt;If your category is something like the name of a street, such as "Elm" "Oak" "Main" "Front" "Jackson" there may not be any obvious order though geographic, such as east to west, might be possible. Where the eastern (or western) street comes "before" the others. Again, assign a numeric value to another variable to go with each name, possibly the number of blocks from a reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is nothing obvious for a natural order, then what would be the meaning of the quartile on what would be, essentially, a random order assignment?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2022 21:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801195#M315297</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-09T21:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to get quartiles from a categorical variable with 100 levels?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801214#M315300</link>
      <description>To me that seems fine, although loosing some granularity compared to continuous variable. Say there were four people, and they smoked 1, 2, 3, 4 cigarettes, respectively, or, you can say, they smoked little, moderate, many, and very many cigarettes, that would still be four quartiles. However, if you define 2-3 cigarettes as moderate, now we cannot have four quartiles anymore with categories, because two people will belong to moderate category. So the key here is, before you create categories of the categorical variable, to look at the rank boundaries of sorted continuous variable, so you can partition the categories neatly and there are really four quartiles of more or less equal size.</description>
      <pubDate>Thu, 10 Mar 2022 03:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-it-possible-to-get-quartiles-from-a-categorical-variable-with/m-p/801214#M315300</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2022-03-10T03:19:59Z</dc:date>
    </item>
  </channel>
</rss>

