<?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: Creating a categorical variable off of percentile data. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610506#M177789</link>
    <description>&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pardon my ignorance...I'm very new to this. The only proc means I know is as follows, which doesn't give me the percentages that I'm looking for. Is there a way to specify that I want 80th% instead of the Q3 (75th)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=temp.execdata nolabels n q1 q3 mean median min max std;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Dec 2019 16:35:09 GMT</pubDate>
    <dc:creator>anweinbe</dc:creator>
    <dc:date>2019-12-09T16:35:09Z</dc:date>
    <item>
      <title>Creating a categorical variable off of percentile data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610501#M177784</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a file of individuals names and their change in ownership %'s between 1%-100%. There are approximately 500 records.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like this:&lt;/P&gt;
&lt;P&gt;Smith&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5%&lt;/P&gt;
&lt;P&gt;Jones&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10%&lt;/P&gt;
&lt;P&gt;Mary&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7%.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a field that assigns each of the records to a higher level grouping if they are in the top 75th percentile of % change (labeled TOP), another group if they are in the 20th-75th (labeled middle), and a 3rd group if they are in 0-19th (labeled bottom).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried proc means but that puts the stats into a table, it also doesn't help me with the middle groupings.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 16:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610501#M177784</guid>
      <dc:creator>anweinbe</dc:creator>
      <dc:date>2019-12-09T16:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a categorical variable off of percentile data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610504#M177787</link>
      <description>&lt;P&gt;You can &lt;A href="https://blogs.sas.com/content/iml/2019/06/10/5-reasons-to-use-proc-format-to-recode-variables-in-sas.html" target="_self"&gt;use PROC FORMAT to recode a variable.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;For your particular application, this is equivalent to &lt;A href="https://blogs.sas.com/content/iml/2016/08/08/sas-formats-bin-numerical-variables.html" target="_self"&gt;using PROC FORMAT to bin a variable.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can run PROC MEANS to get the percentiles and then enter them manually into the VALUE statement in PROC FORMAT. Or if you want to automate the process, you can &lt;A href="https://go.documentation.sas.com/?docsetId=proc&amp;amp;docsetTarget=n1e19y6lrektafn1kj6nbvhus59w.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#n1e19y6lrektafn1kj6nbvhus59w" target="_self"&gt;use the CNTLIN= option on PROC FORMAT&lt;/A&gt; to specify the name of a SAS data set that defines the percentiles.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the manual option, suppose from PROC MEANS that the cutpoints for the three groups are 0.02 and 0.08. Then the PROC FORMAT would look like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value PctlFmt  
      low  -&amp;lt;  0.02  = "Bottom"
      0.02  -&amp;lt;  0.08 = "Middle"
      0.08  -   high = "Top"
      ;
run;

data Have;
length Name $10;
input Name $ pct;
format pct PERCENT8.2;
datalines;
Smith  0.05
Jones  0.10
Mary   0.07
Thomas 0.012
Xu     0.03
;

proc print data=Have;
format Pct PctlFmt.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Dec 2019 16:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610504#M177787</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-12-09T16:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a categorical variable off of percentile data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610506#M177789</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pardon my ignorance...I'm very new to this. The only proc means I know is as follows, which doesn't give me the percentages that I'm looking for. Is there a way to specify that I want 80th% instead of the Q3 (75th)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=temp.execdata nolabels n q1 q3 mean median min max std;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 16:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610506#M177789</guid>
      <dc:creator>anweinbe</dc:creator>
      <dc:date>2019-12-09T16:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a categorical variable off of percentile data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610518#M177797</link>
      <description>&lt;P&gt;I would suggest using PROC RANK. If you want percentiles in terms of 5th or 10th percentiles use the appropriate number of groups. The benefit of using this method is that you don't have to figure out the cutoffs and then group the variables, it's done in a single step.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;This will create a new variable, mpg_city_rank in the data set cars that will be the values 0 to 19 and 0 is the 0 to 5th percentile, and 19th would be 95th to 100th percentile idea.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you used groups =10 it would be the 0 to 10th percentile and so forth.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc rank data=sashelp.cars out=cars groups=20;
var mpg_city;
ranks mpg_city_rank;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/287480"&gt;@anweinbe&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Good morning,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a file of individuals names and their change in ownership %'s between 1%-100%. There are approximately 500 records.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like this:&lt;/P&gt;
&lt;P&gt;Smith&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5%&lt;/P&gt;
&lt;P&gt;Jones&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10%&lt;/P&gt;
&lt;P&gt;Mary&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7%.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a field that assigns each of the records to a higher level grouping if they are in the top 75th percentile of % change (labeled TOP), another group if they are in the 20th-75th (labeled middle), and a 3rd group if they are in 0-19th (labeled bottom).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried proc means but that puts the stats into a table, it also doesn't help me with the middle groupings.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 17:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610518#M177797</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-09T17:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a categorical variable off of percentile data.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610519#M177798</link>
      <description>&lt;P&gt;Or via PROC MEANS:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2013/10/23/percentiles-in-a-tabular-format.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2013/10/23/percentiles-in-a-tabular-format.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or for custom percentiles:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/faq/how-do-i-obtain-percentiles-not-automatically-calculated/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/faq/how-do-i-obtain-percentiles-not-automatically-calculated/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2019 17:26:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-categorical-variable-off-of-percentile-data/m-p/610519#M177798</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-09T17:26:16Z</dc:date>
    </item>
  </channel>
</rss>

