<?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: quartiles for categorical variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479222#M123659</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9263"&gt;@sfo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;For example I have gender with values F and M and I need to divide all F in 4 quartiles and all M in 4 quartiles.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Using what criteria would you do this dividing into quartiles? Explain please! Give an example.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jul 2018 19:15:08 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-07-18T19:15:08Z</dc:date>
    <item>
      <title>quartiles for categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479154#M123634</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Is there a way to divide the categorical into 4 quartiles?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example I have gender with values F and M and I need to divide all F in 4 quartiles and all M in 4 quartiles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know for numeric we can use proc rank but what is the equivalent for categorical?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 17:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479154#M123634</guid>
      <dc:creator>sfo</dc:creator>
      <dc:date>2018-07-18T17:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: quartiles for categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479165#M123639</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9263"&gt;@sfo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;Is there a way to divide the categorical into 4 quartiles?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example I have gender with values F and M and I need to divide all F in 4 quartiles and all M in 4 quartiles.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know for numeric we can use proc rank but what is the equivalent for categorical?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you need to provide some example data and what you want the output to look like given that example data. You are using "quartile" in a non-standard way so a more specific example will be helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean to assign the data into 4 groups fore each sex that are roughly the same size? Does the assignment have to be random? If so perhaps:&lt;/P&gt;
&lt;P&gt;Proc sort data=have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; by sex;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Proc surveyselect data=have out=want groups=4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; strata sex;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 17:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479165#M123639</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-18T17:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: quartiles for categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479222#M123659</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9263"&gt;@sfo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;For example I have gender with values F and M and I need to divide all F in 4 quartiles and all M in 4 quartiles.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Using what criteria would you do this dividing into quartiles? Explain please! Give an example.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 19:15:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479222#M123659</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-18T19:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: quartiles for categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479242#M123665</link>
      <description>&lt;P&gt;Thanks for the solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does it work on 9.2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting an error:&lt;/P&gt;
&lt;P&gt;436 Proc surveyselect data=fdaada_popPK out=want groups=4;&lt;BR /&gt; ------&lt;BR /&gt; 22&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, (, CERTAIN, CERTSIZE, DATA, JTPROBS, M, MAXSIZE, METHOD,&lt;BR /&gt; MINSIZE, N, NMAX, NMIN, NOPRINT, OUT, OUTALL, OUTHITS, OUTSEED, OUTSIZE, OUTSORT, RATE, REPS, SAMPRATE, SAMPSIZE,&lt;BR /&gt; SEED, SELECTALL, SORT, SRSALG, STATS.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 20:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479242#M123665</guid>
      <dc:creator>sfo</dc:creator>
      <dc:date>2018-07-18T20:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: quartiles for categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479297#M123680</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/9263"&gt;@sfo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for the solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does it work on 9.2?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting an error:&lt;/P&gt;
&lt;P&gt;436 Proc surveyselect data=fdaada_popPK out=want groups=4;&lt;BR /&gt; ------&lt;BR /&gt; 22&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, (, CERTAIN, CERTSIZE, DATA, JTPROBS, M, MAXSIZE, METHOD,&lt;BR /&gt; MINSIZE, N, NMAX, NMIN, NOPRINT, OUT, OUTALL, OUTHITS, OUTSEED, OUTSIZE, OUTSORT, RATE, REPS, SAMPRATE, SAMPSIZE,&lt;BR /&gt; SEED, SELECTALL, SORT, SRSALG, STATS.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, the Groups=option was added in 9.3 (I think).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If Randomness is not an issue this is another way:&lt;/P&gt;
&lt;P&gt;Using a SAS set you should have as a starting point:&lt;/P&gt;
&lt;PRE&gt;proc sort data=sashelp.class out=work.class;
   by sex;
run;

data work.want;
   set work.class;
   by sex;
   group= mod(_n_,4)+1;
run;&lt;/PRE&gt;
&lt;P&gt;Which will evenly distribute the group identifier within the BY variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479297#M123680</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-18T21:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: quartiles for categorical variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479300#M123683</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;wrote:&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;If Randomness is not an issue this is another way:&lt;/P&gt;
&lt;P&gt;Using a SAS set you should have as a starting point:&lt;/P&gt;
&lt;PRE&gt;proc sort data=sashelp.class out=work.class;
   by sex;
run;

data work.want;
   set work.class;
   by sex;
   group= mod(_n_,4)+1;
run;&lt;/PRE&gt;
&lt;P&gt;Which will evenly distribute the group identifier within the BY variable.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And if randomness is an issue, then you can assign random numbers to each observation and use those to split the data into 4 groups.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 21:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/quartiles-for-categorical-variable/m-p/479300#M123683</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-07-18T21:46:38Z</dc:date>
    </item>
  </channel>
</rss>

