<?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 Percentile in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958018#M373937</link>
    <description>Hello&lt;BR /&gt;I want to calculate percentile 3 and 6 (for yearly salary)+only for people with salary higher than 0.&lt;BR /&gt;Then I want to classify each person ( also classify people with salary 0)to one of 3 groups-&lt;BR /&gt;If salary lower equal percentile 3 then ind=1.&lt;BR /&gt;Else if salary higher percentile 3 and lower equal percentile 6 then ind=2.&lt;BR /&gt;Else if salary higher percentile 6 than ind=3.&lt;BR /&gt;I want to know how to do it via proc rank and not proc univaraite.&lt;BR /&gt;Please note again-&lt;BR /&gt;Percentile is calculated for people with salary higher than 0 only.&lt;BR /&gt;Classification is done for all people included people with salary 0</description>
    <pubDate>Mon, 03 Feb 2025 14:47:48 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2025-02-03T14:47:48Z</dc:date>
    <item>
      <title>Percentile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958018#M373937</link>
      <description>Hello&lt;BR /&gt;I want to calculate percentile 3 and 6 (for yearly salary)+only for people with salary higher than 0.&lt;BR /&gt;Then I want to classify each person ( also classify people with salary 0)to one of 3 groups-&lt;BR /&gt;If salary lower equal percentile 3 then ind=1.&lt;BR /&gt;Else if salary higher percentile 3 and lower equal percentile 6 then ind=2.&lt;BR /&gt;Else if salary higher percentile 6 than ind=3.&lt;BR /&gt;I want to know how to do it via proc rank and not proc univaraite.&lt;BR /&gt;Please note again-&lt;BR /&gt;Percentile is calculated for people with salary higher than 0 only.&lt;BR /&gt;Classification is done for all people included people with salary 0</description>
      <pubDate>Mon, 03 Feb 2025 14:47:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958018#M373937</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-02-03T14:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: Percentile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958020#M373939</link>
      <description>&lt;P&gt;What did you try? How did it work out?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to start by making a new variable that copies SALARY but sets zeros to missing.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if salary&amp;gt;0 then salary2 = salary;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use that to find your percentile ranks.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 15:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958020#M373939</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-03T15:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Percentile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958021#M373940</link>
      <description>&lt;P&gt;Why are you peculiar what PROC to use?&lt;/P&gt;
&lt;P&gt;You can also accomplish this using MEANS/SUMMARY.&lt;/P&gt;
&lt;P&gt;What are your actual constraints?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 15:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958021#M373940</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2025-02-03T15:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Percentile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958079#M373957</link>
      <description>I must use proc rank.&lt;BR /&gt;Why? People from my work want to make similar programs that in different models calculation be made same way....I know it is funny but it is the truth</description>
      <pubDate>Mon, 03 Feb 2025 18:30:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958079#M373957</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-02-03T18:30:54Z</dc:date>
    </item>
    <item>
      <title>This is my code (working 100%) However' I was asked to do...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958114#M373970</link>
      <description>&lt;P&gt;This is my code (working 100%)&lt;/P&gt;
&lt;P&gt;However' I was asked to do it via proc rank and&amp;nbsp; not proc univariate.&lt;/P&gt;
&lt;P&gt;Can you please show the code via proc rank that provide same result?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data =raw_data(Where=(Income_NOEXT_AMT&amp;gt;0))  noprint;
var Income_NOEXT_AMT;
output out=P_Income_tbl  PCTLPTS =3,6   PCTLPRE =P;
run;

Data WANT;
set raw_data;
If _N_=1 then set P_Income_tbl;
IF Income_NOEXT_AMT=0 then _Income_NOEXT_AMT=1;
else IF Income_NOEXT_AMT&amp;gt;0 AND Income_NOEXT_AMT&amp;lt;=P3 then _Income_NOEXT_AMT=2;
else IF Income_NOEXT_AMT&amp;gt;P3 AND Income_NOEXT_AMT&amp;lt;=P6 then  _Income_NOEXT_AMT=3;
else IF Income_NOEXT_AMT&amp;gt;P6 then _Income_NOEXT_AMT=4; 
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Feb 2025 20:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958114#M373970</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-02-03T20:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: Percentile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958116#M373972</link>
      <description>&lt;P&gt;I was asked to use proc rank only&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 20:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958116#M373972</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-02-03T20:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Percentile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958127#M373977</link>
      <description>&lt;P&gt;Okay,&lt;/P&gt;
&lt;P&gt;Here is the solution&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 

Data raw_data;
set raw_data;
IF Income_NOEXT_AMT&amp;gt;0 then _Income_NOEXT_AMT_=Income_NOEXT_AMT;
Run;

proc rank data=raw_data out=want_rank(KEEP=lakoach _Income_NOEXT_AMT_  rank) groups=100;
var _Income_NOEXT_AMT_;
ranks rank;
run;
proc sort data=want_rank;
by rank;
run;

proc sql;
create table want_rank_b(KEEP=maxx P rename=(maxx=value)) as
select rank+1 as P,
         min(_Income_NOEXT_AMT_) as minn,
		 max(_Income_NOEXT_AMT_) as maxx
from want_rank
where rank in (2,5)
group by calculated P
;
quit;
/*rank=2 (percentile=3)*/
/*rank=5 (percentile=6)*/
 
proc transpose data=want_rank_b out=P_Income_tbl(DROP=_name_) prefix=P;
var value;
ID P;
Run;

/*proc univariate data =raw_data(Where=(Income_NOEXT_AMT&amp;gt;0))  noprint;*/
/*var Income_NOEXT_AMT;*/
/*output out=P_MACHZOR_tbl  PCTLPTS =3,6   PCTLPRE =P;*/
/*run;*/

Data WANT;
set raw_data;
If _N_=1 then set P_Income_tbl;
IF Income_NOEXT_AMT=0 then IND=1;
else IF Income_NOEXT_AMT&amp;gt;0 AND Income_NOEXT_AMT&amp;lt;=P3 then IND=2;
else IF Income_NOEXT_AMT&amp;gt;P3 AND Income_NOEXT_AMT&amp;lt;=P6 then  IND=3;
else IF Income_NOEXT_AMT&amp;gt;P6 then IND=4; 
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Feb 2025 21:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958127#M373977</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-02-03T21:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Percentile</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958165#M373990</link>
      <description>&lt;P&gt;This is exactly what I needed in order to&amp;nbsp; calculate it.thank you so much&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 05:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Percentile/m-p/958165#M373990</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-02-04T05:41:17Z</dc:date>
    </item>
  </channel>
</rss>

