<?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: compare last column with one column before last in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486295#M126513</link>
    <description>&lt;P&gt;In last column we have :1,2,3,5,9,10,11&lt;/P&gt;&lt;P&gt;In one column before last column we have:1,2,3,5,8,9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Common members are: 1,2,3,5,9&lt;/P&gt;&lt;P&gt;New members(Exist in last but not in column before); 10,11&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Left members(Exist in column before but not in last column);&amp;nbsp;8&lt;/SPAN&gt;&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Aug 2018 08:53:24 GMT</pubDate>
    <dc:creator>Ronein</dc:creator>
    <dc:date>2018-08-13T08:53:24Z</dc:date>
    <item>
      <title>compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486272#M126501</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have the following challenge.&lt;/P&gt;&lt;P&gt;Let's say that there is an input data set .&lt;/P&gt;&lt;P&gt;I want to check which numbers in last column are new in comparison to previous column(one column before last column).&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to check which numbers in one column before last column are not existing&amp;nbsp;in last column.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think that in the program we need to check how many columns are in in input data set and then we can compare&amp;nbsp;last column with one column before last.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In the following&amp;nbsp;example if we compare last column with one column before last:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;9,10,11 &amp;nbsp;are new&amp;nbsp;&lt;/SPAN&gt;members&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;8,9 left&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want to create a new outcome data set &amp;nbsp;with two columns: new and left&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tbl;
input x1801 x1802 x1803 x1804 x1805 x1806;
cards;
1 1 6 1 1 2
2 2 1 2 2 3
3 3 2 3 3 4
4 4 3 4 5 5
5 5 4 8 8 8
    5 9 9 10
;
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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 07:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486272#M126501</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-13T07:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486278#M126503</link>
      <description>&lt;P&gt;If you compare the last&amp;nbsp;&lt;EM&gt;column&lt;/EM&gt;&amp;nbsp;with the next-to-last&amp;nbsp;&lt;EM&gt;column&lt;/EM&gt;, you compare x1806 to x1805. With that, you'd get this output:&lt;/P&gt;
&lt;PRE&gt;2
3
4
10&lt;/PRE&gt;
&lt;P&gt;I think you meant to compare the 6th&amp;nbsp;&lt;EM&gt;row&lt;/EM&gt; with the contents of the 5th?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 08:08:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486278#M126503</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-13T08:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486282#M126505</link>
      <description>&lt;P&gt;Try next code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let vars = x1801 x1802 x1803 x1804 x1805 x1806;
data tbl;
    retain maxv; drop maxv;
    maxv = countw("&amp;amp;vars");

    input &amp;amp;vars;

    array vx &amp;amp;vars;
    if vx(maxv) = vx(maxv -1) then ... ;
    else ..... ;

cards;
1 1 6 1 1 2
2 2 1 2 2 3
3 3 2 3 3 4
4 4 3 4 5 5
5 5 4 8 8 8
    5 9 9 10
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 08:14:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486282#M126505</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-08-13T08:14:19Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486283#M126506</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;In each column I have list of customers which belong to club.&lt;/P&gt;&lt;P&gt;The target is to identify new customer and customers who left .&lt;/P&gt;&lt;P&gt;The comparison is just between last column and one column before last (&lt;SPAN&gt; next-to-last&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;column).&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The issue is that the input table including columns from start of year (JAN) until lat month.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;So in June the last column is 1806 and in July last column is 1807 &amp;nbsp;and so on.&lt;BR /&gt;The first question&amp;nbsp;is to perform analysis(Merge) of last column with&amp;nbsp;&lt;SPAN&gt;next-to-last&amp;nbsp;&lt;/SPAN&gt;column.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;In the merge I don't want to say to merge X1806 with X1805....&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;I want to say to merge last column with&amp;nbsp;&lt;SPAN&gt;next-to-last&amp;nbsp;&lt;/SPAN&gt;column&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;thanks&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 08:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486283#M126506</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-13T08:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486286#M126508</link>
      <description>&lt;P&gt;Can you show what you want out at the end?&amp;nbsp; Not following your logic as:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"9,10,11 &amp;nbsp;are new&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;members" - 11 is not in the data you present.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"8,9 left" - what does this mean?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Generally you can assign an array, and then use the elements:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; tbl&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;  input&lt;/SPAN&gt; x1801 x1802 x1803 x1804 x1805 x1806&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;  array x{6};&lt;BR /&gt;  if x{5} ne x{6} then not_equal="Y";
&lt;SPAN class="token datalines"&gt;&lt;SPAN class="token keyword"&gt;cards&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;
1 1 6 1 1 2
2 2 1 2 2 3
3 3 2 3 3 4
4 4 3 4 5 5
5 5 4 8 8 8
    5 9 9 10
&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Shows comparing last to position 5.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 08:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486286#M126508</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-13T08:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486288#M126509</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;In each column I have list of customers which belong to club.&lt;/P&gt;
&lt;P&gt;The target is to identify new customer and customers who left .&lt;/P&gt;
&lt;P&gt;The comparison is just between last column and one column before last (&lt;SPAN&gt; next-to-last&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;column).&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;The issue is that the input table including columns from start of year (JAN) until lat month.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;So in June the last column is 1806 and in July last column is 1807 &amp;nbsp;and so on.&lt;BR /&gt;The first question&amp;nbsp;is to perform analysis(Merge) of last column with&amp;nbsp;&lt;SPAN&gt;next-to-last&amp;nbsp;&lt;/SPAN&gt;column.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;In the merge I don't want to say to merge X1806 with X1805....&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I want to say to merge last column with&amp;nbsp;&lt;SPAN&gt;next-to-last&amp;nbsp;&lt;/SPAN&gt;column&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;thanks&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Define an array (say var), and compare var{dim(var)} with var{dim(var)-1}.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 08:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486288#M126509</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-13T08:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486289#M126510</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;In each column I have list of customers which belong to club.&lt;/P&gt;
&lt;P&gt;The target is to identify new customer and customers who left .&lt;/P&gt;
&lt;P&gt;The comparison is just between last column and one column before last (&lt;SPAN&gt; next-to-last&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;column).&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;The issue is that the input table including columns from start of year (JAN) until lat month.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;So in June the last column is 1806 and in July last column is 1807 &amp;nbsp;and so on.&lt;BR /&gt;The first question&amp;nbsp;is to perform analysis(Merge) of last column with&amp;nbsp;&lt;SPAN&gt;next-to-last&amp;nbsp;&lt;/SPAN&gt;column.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;In the merge I don't want to say to merge X1806 with X1805....&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I want to say to merge last column with&amp;nbsp;&lt;SPAN&gt;next-to-last&amp;nbsp;&lt;/SPAN&gt;column&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;thanks&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Define an array (say var), and compare var{dim(var)} with var{dim(var)-1}.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 08:21:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486289#M126510</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-13T08:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486290#M126511</link>
      <description>&lt;P&gt;It is nice but in your code the user need to enter manually list of columns(% let ).&lt;/P&gt;&lt;P&gt;The task is to do it automatically (without user definition of the columns names)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 08:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486290#M126511</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-13T08:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486291#M126512</link>
      <description>&lt;P&gt;You also suffer (once again) from a dumb data model that keeps data (months) in structure (variable names).&lt;/P&gt;
&lt;P&gt;I'm quite sure that an intelligent model will make a solution (once we know what you really want) MUCH easier.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 08:31:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486291#M126512</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-13T08:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486295#M126513</link>
      <description>&lt;P&gt;In last column we have :1,2,3,5,9,10,11&lt;/P&gt;&lt;P&gt;In one column before last column we have:1,2,3,5,8,9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Common members are: 1,2,3,5,9&lt;/P&gt;&lt;P&gt;New members(Exist in last but not in column before); 10,11&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Left members(Exist in column before but not in last column);&amp;nbsp;8&lt;/SPAN&gt;&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 08:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486295#M126513</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-13T08:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486298#M126514</link>
      <description>&lt;P&gt;There is&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;No&lt;/STRONG&gt;&lt;/U&gt; 11 in the test data you presented.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 09:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486298#M126514</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-13T09:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486307#M126517</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have the following challenge.&lt;/P&gt;
&lt;P&gt;Let's say that there is an input data set .&lt;/P&gt;
&lt;P&gt;I want to check which numbers in last column are new in comparison to previous column(one column before last column).&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want to check which numbers in one column before last column are not existing&amp;nbsp;in last column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I think that in the program we need to check how many columns are in in input data set and then we can compare&amp;nbsp;last column with one column before last.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the following&amp;nbsp;example if we compare last column with one column before last:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;9,10,11 &amp;nbsp;are new&amp;nbsp;&lt;/SPAN&gt;members&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;8,9 left&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want to create a new outcome data set &amp;nbsp;with two columns: new and left&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tbl;
input x1801 x1802 x1803 x1804 x1805 x1806;
cards;
1 1 6 1 1 2
2 2 1 2 2 3
3 3 2 3 3 4
4 4 3 4 5 5
5 5 4 8 8 8
    5 9 9 10
;
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;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should make it a habit to check-read your posts. NO 11. Nowhere.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 10:13:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486307#M126517</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-13T10:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486308#M126518</link>
      <description>&lt;P&gt;It is easy to get list of available variables in a data set, by:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select name into : vars separated by ' '
   from dictionary.columns
   where libname = "WORK' and memname = 'TBL' ;
quit;
%put &amp;amp;vars;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then use it in my original code.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 10:14:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486308#M126518</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-08-13T10:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486340#M126529</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; remarked, your initial data model is not very good. But I know how it is: somebody gave you this Excel file for whatever...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given this data&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tbl;
input x1801 x1802 x1803 x1804 x1805 x1806;
cards;
1 1 6 1 1 2
2 2 1 2 2 3
3 3 2 3 3 4
4 4 3 4 5 5
5 5 4 8 8 8
. . 5 9 9 10
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would start by changing it to a long format:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data long;
  set tbl;
  array months x:;
  length month $4;
  if _N_=1 then 
    call symputx('last_month',substr(vname(months(dim(months))),2));
  do _N_=1 to dim(months);
    if months(_N_)=. then &lt;BR /&gt;      continue;
    month=substr(vname(months(_N_)),2);
    member_id=months(_N_);
    output;
    end;
  keep month member_id;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I understand that you do not want to have to enter all the variable names every time, as the number of months&amp;nbsp; may change. Hence the "x:" construct. To see if a member left the club, we have to see if they were still there the last month. So I used the SYMPUTX to put the last month into a macro variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I would sort the data, and finally run through it to see when the individual members came and left:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort;
  by member_id month;
run;

data want;
  do until(last.member_id);
    set long;
	by member_id;
	if first.member_id then
	  new=month;
	end;
  if month&amp;lt;"&amp;amp;last_month" then
    left=month;
  drop month;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Aug 2018 12:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486340#M126529</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-08-13T12:59:13Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486368#M126540</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have the following challenge.&lt;/P&gt;
&lt;P&gt;Let's say that there is an input data set .&lt;/P&gt;
&lt;P&gt;I want to check which numbers in last column are new in comparison to previous column(one column before last column).&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want to check which numbers in one column before last column are not existing&amp;nbsp;in last column.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I think that in the program we need to check how many columns are in in input data set and then we can compare&amp;nbsp;last column with one column before last.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In the following&amp;nbsp;example if we compare last column with one column before last:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;9,10,11 &amp;nbsp;are new&amp;nbsp;&lt;/SPAN&gt;members&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;8,9 left&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want to create a new outcome data set &amp;nbsp;with two columns: new and left&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tbl;
input x1801 x1802 x1803 x1804 x1805 x1806;
cards;
1 1 6 1 1 2
2 2 1 2 2 3
3 3 2 3 3 4
4 4 3 4 5 5
5 5 4 8 8 8
    5 9 9 10
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Does this requirement have anything to do with a data source that you keep "adding columns" to a base data set?&lt;/P&gt;
&lt;P&gt;If so fix the data model. You are making lots of assumptions of what "last column" might mean and there is difficult to be sure that the columns you compare are what you think they are if the columns keep changing.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 14:52:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486368#M126540</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-13T14:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: compare last column with one column before last</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486544#M126611</link>
      <description>&lt;P&gt;Sorry&lt;/P&gt;&lt;P&gt;Common memebers: &amp;nbsp;2,3,5,8,&lt;/P&gt;&lt;P&gt;New memebers: 4,10&lt;/P&gt;&lt;P&gt;Left members: 1,9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 06:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-last-column-with-one-column-before-last/m-p/486544#M126611</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-08-14T06:11:12Z</dc:date>
    </item>
  </channel>
</rss>

