<?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: Building clusters using distribution percentiles in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Building-clusters-using-distribution-percentiles/m-p/281937#M57224</link>
    <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  do VAR1= 1 to 1e3;
    VAR2=ranuni(0);
    VAR3=ranuni(0);
    output;
  end;
run;     

%macro percentiles(k);

proc univariate data = HAVE noprint;
	var VAR1 VAR2 VAR3 ;
	output out      = PERCENTILES
		   	 pctlpts  = %do i=1 %to 100;&amp;amp;i %end;
			   pctlpre  = VAR1_ VAR2_ VAR3_;
run;

data WANT;
  set HAVE;
  if _N_=1 then set PERCENTILES;
  %do i=0 %to 99;
    if %if &amp;amp;i=0 %then .; %else VAR1_&amp;amp;i; &amp;lt; VAR1 &amp;lt;=VAR1_%eval(&amp;amp;i+1) then VAR1_IN_PCT&amp;amp;i =1;
    if %if &amp;amp;i=0 %then .; %else VAR2_&amp;amp;i; &amp;lt; VAR2 &amp;lt;=VAR2_%eval(&amp;amp;i+1) then VAR2_IN_PCT&amp;amp;i =1;
    if %if &amp;amp;i=0 %then .; %else VAR3_&amp;amp;i; &amp;lt; VAR3 &amp;lt;=VAR3_%eval(&amp;amp;i+1) then VAR3_IN_PCT&amp;amp;i =1;
  %end; 
  drop VAR1_1--VAR3_100;
run;   
 
%mend;       

%percentiles;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 04 Jul 2016 02:34:59 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2016-07-04T02:34:59Z</dc:date>
    <item>
      <title>Building clusters using distribution percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-clusters-using-distribution-percentiles/m-p/281898#M57205</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I computed the variables distribution&amp;nbsp;percentiles by using the following macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%MACRO PERCENTILES(K);

PROC UNIVARIATE DATA = lib.c NOPRINT;
	VAR var1 var2 var3
		OUTPUT OUT = lib.PERCENTILES_&amp;amp;K.
			PCTLPTS = &amp;amp;K. /* k-th quartile */
			PCTLPRE = var1 var2 var3
		PCTLNAME = _P&amp;amp;K.;
RUN;

%MEND;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, I would like to construct a set of dummy variables for each continuous variables assuming value equal to 1 if the correspondent value of the continuous variable drops in the quantiles range and 0 otherwise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For istance, let's assume the var1 has the first percentile equal to 0.0124; the first dummy variable relative to var1 will have value equal to 1 if var1 is less or equal to 0.0124 and 0 otherwise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone of you suggest how I can get such dummy variables?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hint will be appreciated.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Jul 2016 10:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-clusters-using-distribution-percentiles/m-p/281898#M57205</guid>
      <dc:creator>Quantopic</dc:creator>
      <dc:date>2016-07-03T10:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Building clusters using distribution percentiles</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Building-clusters-using-distribution-percentiles/m-p/281937#M57224</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
  do VAR1= 1 to 1e3;
    VAR2=ranuni(0);
    VAR3=ranuni(0);
    output;
  end;
run;     

%macro percentiles(k);

proc univariate data = HAVE noprint;
	var VAR1 VAR2 VAR3 ;
	output out      = PERCENTILES
		   	 pctlpts  = %do i=1 %to 100;&amp;amp;i %end;
			   pctlpre  = VAR1_ VAR2_ VAR3_;
run;

data WANT;
  set HAVE;
  if _N_=1 then set PERCENTILES;
  %do i=0 %to 99;
    if %if &amp;amp;i=0 %then .; %else VAR1_&amp;amp;i; &amp;lt; VAR1 &amp;lt;=VAR1_%eval(&amp;amp;i+1) then VAR1_IN_PCT&amp;amp;i =1;
    if %if &amp;amp;i=0 %then .; %else VAR2_&amp;amp;i; &amp;lt; VAR2 &amp;lt;=VAR2_%eval(&amp;amp;i+1) then VAR2_IN_PCT&amp;amp;i =1;
    if %if &amp;amp;i=0 %then .; %else VAR3_&amp;amp;i; &amp;lt; VAR3 &amp;lt;=VAR3_%eval(&amp;amp;i+1) then VAR3_IN_PCT&amp;amp;i =1;
  %end; 
  drop VAR1_1--VAR3_100;
run;   
 
%mend;       

%percentiles;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Jul 2016 02:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Building-clusters-using-distribution-percentiles/m-p/281937#M57224</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-07-04T02:34:59Z</dc:date>
    </item>
  </channel>
</rss>

