<?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: Using the PCTL function in a DATA step? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270521#M53769</link>
    <description>&lt;P&gt;You sound like you came from SQL world. Yes, indeed, most of the data step functions work on ONE obs at a time, some times some functions may appear not, however, they still DO. This is due the foundamental data processing structure in data step, aka, PDV (&lt;STRONG&gt;program data vector).&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 14 May 2016 15:59:05 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2016-05-14T15:59:05Z</dc:date>
    <item>
      <title>Using the PCTL function in a DATA step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270425#M53730</link>
      <description>&lt;P&gt;Can I use the PCTL function this way in a DATA step? The answer appears to be no...I'm trying to remove outliers to look at the distribution of a variable w/o them. My objective in the syntax below is to remove values of age GE the 75th percentile and LE the 25th percentile, so that I can look at the distribution w/o outliers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;	data test_2; 
	set data.SMART_a1_a5_final;
	
        do timepoint = "A1", "A2", "A3", "A4", "A5";
 	  IF AGE GE PCTL(75,age) THEN DELETE; 
 	  IF AGE LE PCTL(25,age) THEN DELETE; 
	end;
	RUN;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2016 19:11:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270425#M53730</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2016-05-13T19:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using the PCTL function in a DATA step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270427#M53732</link>
      <description>Age always equal to pctl(75,age) or pctl(25,age). What do you want to achieve? There should be more than one elements in the place of 'age' if you are looking at 'percentile',  otherwise, it always returns the 'age'.  Please refer to SAS docs for details.</description>
      <pubDate>Fri, 13 May 2016 18:50:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270427#M53732</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-05-13T18:50:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using the PCTL function in a DATA step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270428#M53733</link>
      <description>Please show some data. That is usually the best way to illustrate your problem.</description>
      <pubDate>Fri, 13 May 2016 18:53:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270428#M53733</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-05-13T18:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Using the PCTL function in a DATA step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270431#M53734</link>
      <description>&lt;P&gt;Functions in a dataset operate on the values within a specific row.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want values for a column you'll need to use a proc to get the percentiles first and then filter them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Univariate and Proc means can calculate percentiles, univariate has more percentiles available, while proc means does the most common values.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2016 19:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270431#M53734</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-13T19:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using the PCTL function in a DATA step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270432#M53735</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;Thanks. Your explanation makes sense. I could use PROC UNIVARIATE and then output the 3Q and 1Q into new variables. I think that's what you are suggesting...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please explain this is a little more. I'm not sure I totally follow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;Functions in a dataset operate on the values within a specific row. &amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As always, thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2016 19:14:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270432#M53735</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2016-05-13T19:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using the PCTL function in a DATA step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270433#M53736</link>
      <description>&lt;P&gt;The functions work on values within the row, so max finds the max of f1 to f4 for each row. Whereas proc means finds the max of f1, the max of f2, etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See a quick example below and compare the output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input f1-f4;
cards;
1 4 5 6
3 7 9 10
1 3 12 3
2 34 3 5
;
run;

data want;
set have;
max_row=max(of f1-f4);
pctl_row=pctl(25, of f1-f4);
run;

proc means data=want pct25 max;
var f1-f4;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 May 2016 19:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270433#M53736</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-13T19:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using the PCTL function in a DATA step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270448#M53743</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;I had no idea that functions only worked across row. Wow. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2016 21:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270448#M53743</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2016-05-13T21:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using the PCTL function in a DATA step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270521#M53769</link>
      <description>&lt;P&gt;You sound like you came from SQL world. Yes, indeed, most of the data step functions work on ONE obs at a time, some times some functions may appear not, however, they still DO. This is due the foundamental data processing structure in data step, aka, PDV (&lt;STRONG&gt;program data vector).&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 May 2016 15:59:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270521#M53769</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-05-14T15:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using the PCTL function in a DATA step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270719#M53831</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;&amp;nbsp;Can you use a function w/o creating a new variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was playing around w/ this syntax w/o success (i.e. "test" is equal to "test_2");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data test;
input age;
datalines;
23
45
65
43
12
21
34
55 ;
run; 

data test_2; 
SET test;    
WHERE age LE PCTL(75,age);    
WHERE SAME AND age GE PCTL(25,age);
RUN;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 May 2016 16:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270719#M53831</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2016-05-16T16:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using the PCTL function in a DATA step?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270724#M53835</link>
      <description>&lt;P&gt;You are still attempting to use a the function suboptimally. ANY percentile of a given single value is that value. So since you use GE or LE then&amp;nbsp; you are doing this comparison:&lt;/P&gt;
&lt;P&gt;Where age le age;&lt;/P&gt;
&lt;P&gt;Where age ge age;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   age = 25;
   do pctl= 1, 10, 25,50;
      result = pctl(pctl,age);
      put 'Percentile'+1 pctl "of " age= "is " result;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But yes, you can use the function without a new variable. I often use code like;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If x is &amp;gt; max(var1,var2,var3) then do ...&lt;/P&gt;</description>
      <pubDate>Mon, 16 May 2016 16:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-the-PCTL-function-in-a-DATA-step/m-p/270724#M53835</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-05-16T16:44:00Z</dc:date>
    </item>
  </channel>
</rss>

