<?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: How to get the 4th and 6th Highest Transaction for each ID and the difference in these transacti in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/564437#M158324</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=a ; by id transaction ; run;

data a_ ;
retain id ;
	set a ;
	by id ;
	if first.id then trans=1 ;
	else trans+1 ;
run;

proc transpose data=a_ out=b prefix=trans_;
	by id ;
	var transaction ;
run;

data b_ (keep=ID trans_4 trans_6 trans_diff) ; 
	set b ;
	trans_diff=(trans_6-trans_4) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Jun 2019 11:47:13 GMT</pubDate>
    <dc:creator>PraneethSrinivas</dc:creator>
    <dc:date>2019-06-07T11:47:13Z</dc:date>
    <item>
      <title>How to get the 4th and 6th Highest Transaction for each ID and the difference in these transactions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/563471#M157974</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS, want to know how I can get the difference between the 4th highest and 6th highest transaction of each ID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample Data:&amp;nbsp;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;input id transaction;&lt;BR /&gt;cards;&lt;BR /&gt;1 200&lt;BR /&gt;1 300&lt;BR /&gt;1 100&lt;BR /&gt;1 500&lt;BR /&gt;1 600&lt;BR /&gt;1 400&lt;BR /&gt;1 700&lt;BR /&gt;2 300&lt;BR /&gt;2 200&lt;BR /&gt;2 300&lt;BR /&gt;2 400&lt;BR /&gt;2 500&lt;BR /&gt;2 800&lt;BR /&gt;2 900&lt;BR /&gt;2 350&lt;BR /&gt;3 200&lt;BR /&gt;3 150&lt;BR /&gt;3 100&lt;BR /&gt;3 50&lt;BR /&gt;3 400&lt;BR /&gt;3 600&lt;BR /&gt;3 900&lt;BR /&gt;3 450&lt;BR /&gt;3 90&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2019 09:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/563471#M157974</guid>
      <dc:creator>Hem_ant</dc:creator>
      <dc:date>2019-06-04T09:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the 4th and 6th Highest Transaction for each ID and the difference in these transacti</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/563477#M157979</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=a out=ta;
by id;
var transaction;
run;

proc sql noprint;
SELECT count(*) INTO :ncols TRIMMED
FROM dictionary.columns
WHERE LIBNAME="WORK" and MEMNAME="TA" AND substr(NAME,1,3)="COL";
quit;

data want;
set ta;
array tran(*) col&amp;amp;ncols.-col1;
call sortn(of tran(*));
diff=COL4-COL6;

keep id diff;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jun 2019 09:37:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/563477#M157979</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-06-04T09:37:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the 4th and 6th Highest Transaction for each ID and the difference in these transacti</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/563510#M157990</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input id transaction;
cards;
1 200
1 300
1 100
1 500
1 600
1 400
1 700
2 300
2 200
2 300
2 400
2 500
2 800
2 900
2 350
3 200
3 150
3 100
3 50
3 400
3 600
3 900
3 450
3 90
;
run;


ods select none;
ods output  ExtremeValues= ExtremeValues(keep=varname id high LowOrder
where=(LowOrder in (4 6)));
proc univariate data=a nextrval=6;
class id;
var transaction;
run;
ods select all;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jun 2019 13:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/563510#M157990</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-06-04T13:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the 4th and 6th Highest Transaction for each ID and the difference in these transacti</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/564437#M158324</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=a ; by id transaction ; run;

data a_ ;
retain id ;
	set a ;
	by id ;
	if first.id then trans=1 ;
	else trans+1 ;
run;

proc transpose data=a_ out=b prefix=trans_;
	by id ;
	var transaction ;
run;

data b_ (keep=ID trans_4 trans_6 trans_diff) ; 
	set b ;
	trans_diff=(trans_6-trans_4) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Jun 2019 11:47:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/564437#M158324</guid>
      <dc:creator>PraneethSrinivas</dc:creator>
      <dc:date>2019-06-07T11:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the 4th and 6th Highest Transaction for each ID and the difference in these transacti</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/564650#M158406</link>
      <description>&lt;P&gt;If there were two same transactions in the same id , your code wouldn't work.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2019 12:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-the-4th-and-6th-Highest-Transaction-for-each-ID-and/m-p/564650#M158406</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-06-08T12:50:46Z</dc:date>
    </item>
  </channel>
</rss>

