<?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: Rank Transformation with mean=0 and std=1 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545320#M74294</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/144925"&gt;@Yegen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I am trying to rank transform a data by year (i.e., rank transformation within cross-section) such that the rank transformed that has a mean of 0 and a standard deviation of 1.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is what I have so far, but I am not able to force proc transform to rank transform the data so that SAS rank transforms the data by having mean=0 and std=1:&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 work.have;
 infile cards expandtabs truncover;
 input id year value;
 cards;
 1 2001 0.4
 2 2001 0.3
 3 2001 0.4
 4 2001 0.8
 5 2001 0.9
 6 2001 0.8
 7 2001 0.8
 1 2002 0.3
 2 2002 0.9
 3 2002 0.1
 4 2002 0.9
 5 2002 0.2
 6 2002 0.9
 7 2002 0.9
;
run;

/*    I want to rank the variable "value" by year such that it has a mean=0 and a std=1 			    */
/*    Please note that the rank needs to be performed within each year (i.e., within the cross-seciton) */
proc rank data=work.have out=work.have_ranked;
   by year;
   var value;
   ranks valueRank;
run;

/* 	Results */ 
proc sql;
	create table work.want as 
	select distinct year, mean(value) as average, std(value) as standard_dev
	from work.have_ranked
	group by year;
quit;
	&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;Any suggestions will be appreciated!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;PROC RANK gives you unstandardized ranks, not what you want, hence the next step. Use PROC STDIZE to transform the rank numbers so that they have mean 0 and variance 1.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2019 17:30:33 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-03-22T17:30:33Z</dc:date>
    <item>
      <title>Rank Transformation with mean=0 and std=1</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545318#M74293</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I am trying to rank transform a data by year (i.e., rank transformation within cross-section) such that the rank transformed that has a mean of 0 and a standard deviation of 1.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is what I have so far, but I am not able to force proc transform to rank transform the data so that SAS rank transforms the data by having mean=0 and std=1:&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 work.have;
 infile cards expandtabs truncover;
 input id year value;
 cards;
 1 2001 0.4
 2 2001 0.3
 3 2001 0.4
 4 2001 0.8
 5 2001 0.9
 6 2001 0.8
 7 2001 0.8
 1 2002 0.3
 2 2002 0.9
 3 2002 0.1
 4 2002 0.9
 5 2002 0.2
 6 2002 0.9
 7 2002 0.9
;
run;

/*    I want to rank the variable "value" by year such that it has a mean=0 and a std=1 			    */
/*    Please note that the rank needs to be performed within each year (i.e., within the cross-seciton) */
proc rank data=work.have out=work.have_ranked;
   by year;
   var value;
   ranks valueRank;
run;

/* 	Results */ 
proc sql;
	create table work.want as 
	select distinct year, mean(value) as average, std(value) as standard_dev
	from work.have_ranked
	group by year;
quit;
	&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;Any suggestions will be appreciated!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 17:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545318#M74293</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2019-03-22T17:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Rank Transformation with mean=0 and std=1</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545320#M74294</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/144925"&gt;@Yegen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;BR /&gt;&lt;BR /&gt;I am trying to rank transform a data by year (i.e., rank transformation within cross-section) such that the rank transformed that has a mean of 0 and a standard deviation of 1.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is what I have so far, but I am not able to force proc transform to rank transform the data so that SAS rank transforms the data by having mean=0 and std=1:&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 work.have;
 infile cards expandtabs truncover;
 input id year value;
 cards;
 1 2001 0.4
 2 2001 0.3
 3 2001 0.4
 4 2001 0.8
 5 2001 0.9
 6 2001 0.8
 7 2001 0.8
 1 2002 0.3
 2 2002 0.9
 3 2002 0.1
 4 2002 0.9
 5 2002 0.2
 6 2002 0.9
 7 2002 0.9
;
run;

/*    I want to rank the variable "value" by year such that it has a mean=0 and a std=1 			    */
/*    Please note that the rank needs to be performed within each year (i.e., within the cross-seciton) */
proc rank data=work.have out=work.have_ranked;
   by year;
   var value;
   ranks valueRank;
run;

/* 	Results */ 
proc sql;
	create table work.want as 
	select distinct year, mean(value) as average, std(value) as standard_dev
	from work.have_ranked
	group by year;
quit;
	&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;Any suggestions will be appreciated!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;PROC RANK gives you unstandardized ranks, not what you want, hence the next step. Use PROC STDIZE to transform the rank numbers so that they have mean 0 and variance 1.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 17:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545320#M74294</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-22T17:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rank Transformation with mean=0 and std=1</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545322#M74295</link>
      <description>&lt;P&gt;Ranks of unique values will&amp;nbsp;be integers 1, 2, 3, ....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It sounds like you want to standardize the values to have mean=0 and std=1. You can do that with PROC STDIZE:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
/*    I want to rank the variable "value" by year such that it has a mean=0 and a std=1 			    */
/*    Please note that the rank needs to be performed within each year (i.e., within the cross-seciton) */
proc stdize data=work.have out=work.have_ranked;
   by year;
   var value;
run;

proc means data=have_ranked;
class year;
var value;
run;

proc print data=have_ranked;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2019 17:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545322#M74295</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-03-22T17:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: Rank Transformation with mean=0 and std=1</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545324#M74296</link>
      <description>&lt;P&gt;Thanks for your helpful replies,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;. I am trying to follow a prior study that claims that they were using a normalized (to have a mean of 0 as well as a unit standard deviation) rank-transformation. Since they were not explicitly mentioning that they standardized the data to have a zero mean and a unit std, I am not sure if your suggestion&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;would produce the same as a normalized rank-transformation?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 17:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545324#M74296</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2019-03-22T17:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Rank Transformation with mean=0 and std=1</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545326#M74297</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, I have tried to use both of your suggestions and the results seem to be similar although the transformed values are different:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.have;
 infile cards expandtabs truncover;
 input id year value;
 cards;
 1 2001 0.4
 2 2001 0.3
 3 2001 0.4
 4 2001 0.8
 5 2001 0.9
 6 2001 0.8
 7 2001 0.8
 1 2002 0.3
 2 2002 0.9
 3 2002 0.1
 4 2002 0.9
 5 2002 0.2
 6 2002 0.9
 7 2002 0.9
;
run;

/*    I want to rank the variable "value" by year such that it has a mean=0 and a std=1 			    */
/*    Please note that the rank needs to be performed within each year (i.e., within the cross-seciton) */
proc rank data=work.have out=work.have_ranked;
   by year;
   var value;
   ranks valueRank;
run;

PROC STANDARD DATA=have_ranked MEAN=0 STD=1 OUT=have_ranked1;
	by year;
	VAR valueRank value;
RUN;

proc means data=have_ranked1;
class year;
var value valueRank;
run;

proc print data=have_ranked1;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;I wanted to see if the rank tranformed values will be similar to the non-rank transformed values after standardizing the data. They seem pretty similar, but not exactly the same.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 17:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545326#M74297</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2019-03-22T17:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Rank Transformation with mean=0 and std=1</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545329#M74298</link>
      <description>Does your data have ties?</description>
      <pubDate>Fri, 22 Mar 2019 17:49:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545329#M74298</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-22T17:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Rank Transformation with mean=0 and std=1</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545330#M74299</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/144925"&gt;@Yegen&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, I have tried to use both of your suggestions and the results seem to be similar although the transformed values are different:&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;I wanted to see if the rank tranformed values will be similar to the non-rank transformed values after standardizing the data. They seem pretty similar, but not exactly the same.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Pretty similar, but not exactly the same? I don't know what that means, you need to show us what you did and what the different results are.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From what I can see,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;and my suggestion are the same, and should produce the same results.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 17:49:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545330#M74299</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-22T17:49:29Z</dc:date>
    </item>
    <item>
      <title>Re: Rank Transformation with mean=0 and std=1</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545337#M74300</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;, I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;suggested that I should use directly the variable "value" in the standardization rather than using the "valueRank" variable. When I use the&amp;nbsp;"value" and&amp;nbsp;"valueRank" variables in the&amp;nbsp;standardization, I get different "standardized values".&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;, there was no mentioning in the paper that I am following whether they have adjusted for ties. So I assume no adjustments were made there..&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 18:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rank-Transformation-with-mean-0-and-std-1/m-p/545337#M74300</guid>
      <dc:creator>Yegen</dc:creator>
      <dc:date>2019-03-22T18:05:27Z</dc:date>
    </item>
  </channel>
</rss>

