<?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: To create a new reverse variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247093#M46290</link>
    <description>&lt;P&gt;Sounds silly&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=haver; by descending salary ; run;

data want;
set have;
set haver(keep=salary rename=salary=reverse_salary);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 31 Jan 2016 04:48:23 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-01-31T04:48:23Z</dc:date>
    <item>
      <title>To create a new reverse variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247091#M46289</link>
      <description>&lt;P&gt;Hi,Everyone,&lt;/P&gt;
&lt;P&gt;I have a question about how to create a new variable which is in the reverse order of another one;&lt;/P&gt;
&lt;P&gt;for instance ,this is the dataset,&lt;/P&gt;
&lt;P&gt;NAME &amp;nbsp; SALARY&lt;/P&gt;
&lt;P&gt;JACK &amp;nbsp; &amp;nbsp;100&lt;/P&gt;
&lt;P&gt;LUCY &amp;nbsp; &amp;nbsp;200&lt;/P&gt;
&lt;P&gt;MIKE &amp;nbsp; &amp;nbsp; 300&lt;/P&gt;
&lt;P&gt;KATE &amp;nbsp; &amp;nbsp;400&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I need is to create a new variable say "SALARY_REVERSE" to make the dataset looks like the follows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NAME SALARY SALARY_REVERSE&lt;/P&gt;
&lt;P&gt;JACK &amp;nbsp; 100 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 400&lt;/P&gt;
&lt;P&gt;LUCY &amp;nbsp; 200 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;300&lt;/P&gt;
&lt;P&gt;MIKE &amp;nbsp; 300 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 200&lt;/P&gt;
&lt;P&gt;KATE &amp;nbsp; 400 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;100&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Sun, 31 Jan 2016 04:23:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247091#M46289</guid>
      <dc:creator>xxz3231</dc:creator>
      <dc:date>2016-01-31T04:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: To create a new reverse variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247093#M46290</link>
      <description>&lt;P&gt;Sounds silly&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=haver; by descending salary ; run;

data want;
set have;
set haver(keep=salary rename=salary=reverse_salary);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 31 Jan 2016 04:48:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247093#M46290</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-01-31T04:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: To create a new reverse variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247095#M46291</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Salary_Reverse=500-Salary;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 31 Jan 2016 05:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247095#M46291</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-31T05:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: To create a new reverse variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247468#M46417</link>
      <description>Hi,Reeza,thank you very much! But the real data is much more complicated, I need a more general solution,PGStats' solution works well,thank you again!</description>
      <pubDate>Tue, 02 Feb 2016 14:24:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247468#M46417</guid>
      <dc:creator>xxz3231</dc:creator>
      <dc:date>2016-02-02T14:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: To create a new reverse variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247469#M46418</link>
      <description>Thank you very much,PG!It works well!</description>
      <pubDate>Tue, 02 Feb 2016 14:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247469#M46418</guid>
      <dc:creator>xxz3231</dc:creator>
      <dc:date>2016-02-02T14:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: To create a new reverse variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247478#M46421</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Let's say the dataset name is test, my solution is below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Label Observation Number;
data test;
set test;
N = _N_;
run;

*Reverse the Order;
proc sort data = test out = test_reverse; by decending _N_;run;

*Relabel Observation Number;
data test_reverse;
set  test_reverse;
N=_N_;
run;

*Merge the two datasets;
data test_combine;
set test test_reverse;
by N;
run;

 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Feb 2016 14:54:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/To-create-a-new-reverse-variable/m-p/247478#M46421</guid>
      <dc:creator>Wang_Yajun</dc:creator>
      <dc:date>2016-02-02T14:54:51Z</dc:date>
    </item>
  </channel>
</rss>

