<?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 colums to create new coloum in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16706#M2356</link>
    <description>Why wouldn't the lag function work?  For example:&lt;BR /&gt;
&lt;BR /&gt;
data start;&lt;BR /&gt;
   input Text:$3. ID:3. Date:mmddyy10.;&lt;BR /&gt;
   format date mmddyy10.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
xyz 123 02/11/2009&lt;BR /&gt;
xyz 123 03/11/2009&lt;BR /&gt;
xyz 123 04/11/2009&lt;BR /&gt;
xyz 123 05/11/2009&lt;BR /&gt;
abc 124 05/11/2009&lt;BR /&gt;
def 125 02/11/2009&lt;BR /&gt;
def 125 03/11/2009&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=start ;&lt;BR /&gt;
   by id descending date;&lt;BR /&gt;
run;&lt;BR /&gt;
data final;&lt;BR /&gt;
   set start;&lt;BR /&gt;
   by id;&lt;BR /&gt;
   date2=lag1(date);&lt;BR /&gt;
   if (first.ID and last.ID) or first.id then call missing(date2);&lt;BR /&gt;
   format date2 mmddyy10.;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=final;&lt;BR /&gt;
   by id date;&lt;BR /&gt;
run;</description>
    <pubDate>Sun, 19 Jun 2011 03:28:30 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2011-06-19T03:28:30Z</dc:date>
    <item>
      <title>compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16703#M2353</link>
      <description>company    id   date&lt;BR /&gt;
xyz       123   02/11/2009&lt;BR /&gt;
xyz       123   03/11/2009&lt;BR /&gt;
abc       124   05/11/2009&lt;BR /&gt;
&lt;BR /&gt;
I have to compute new coloum called date1.In calculating date1,&lt;BR /&gt;
i have to check below conditions.&lt;BR /&gt;
&lt;BR /&gt;
1)compare two consecutive id's(ex: 123 and 123)...if these two id's match&lt;BR /&gt;
second id date should be the new computed coloum date.&lt;BR /&gt;
&lt;BR /&gt;
If two id's doen't match new computed coloum would be blank.&lt;BR /&gt;
&lt;BR /&gt;
Final dataset:&lt;BR /&gt;
&lt;BR /&gt;
company    id   date          date1&lt;BR /&gt;
xyz       123   02/11/2009    03/11/2009 &lt;BR /&gt;
xyz       123   03/11/2009&lt;BR /&gt;
abc       124   05/11/2009&lt;BR /&gt;
&lt;BR /&gt;
How can i do this one?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
sasg</description>
      <pubDate>Sat, 18 Jun 2011 04:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16703#M2353</guid>
      <dc:creator>sasg</dc:creator>
      <dc:date>2011-06-18T04:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16704#M2354</link>
      <description>If this is your objective, a simple solution is to reverse sort the data and do the following:&lt;BR /&gt;
&lt;BR /&gt;
format date1 ddmmyyyy10.;&lt;BR /&gt;
if id = lag(id) then date1 = lag(date);&lt;BR /&gt;
&lt;BR /&gt;
and sort back the data to its original form.&lt;BR /&gt;
Use _N_ to reverse sort the data.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
zilok</description>
      <pubDate>Sat, 18 Jun 2011 23:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16704#M2354</guid>
      <dc:creator>zilok</dc:creator>
      <dc:date>2011-06-18T23:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16705#M2355</link>
      <description>it can be more than two id's ...lag function won't work....is there any other way?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
Bhavani.</description>
      <pubDate>Sun, 19 Jun 2011 02:13:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16705#M2355</guid>
      <dc:creator>sasg</dc:creator>
      <dc:date>2011-06-19T02:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16706#M2356</link>
      <description>Why wouldn't the lag function work?  For example:&lt;BR /&gt;
&lt;BR /&gt;
data start;&lt;BR /&gt;
   input Text:$3. ID:3. Date:mmddyy10.;&lt;BR /&gt;
   format date mmddyy10.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
xyz 123 02/11/2009&lt;BR /&gt;
xyz 123 03/11/2009&lt;BR /&gt;
xyz 123 04/11/2009&lt;BR /&gt;
xyz 123 05/11/2009&lt;BR /&gt;
abc 124 05/11/2009&lt;BR /&gt;
def 125 02/11/2009&lt;BR /&gt;
def 125 03/11/2009&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=start ;&lt;BR /&gt;
   by id descending date;&lt;BR /&gt;
run;&lt;BR /&gt;
data final;&lt;BR /&gt;
   set start;&lt;BR /&gt;
   by id;&lt;BR /&gt;
   date2=lag1(date);&lt;BR /&gt;
   if (first.ID and last.ID) or first.id then call missing(date2);&lt;BR /&gt;
   format date2 mmddyy10.;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=final;&lt;BR /&gt;
   by id date;&lt;BR /&gt;
run;</description>
      <pubDate>Sun, 19 Jun 2011 03:28:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16706#M2356</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2011-06-19T03:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16707#M2357</link>
      <description>thanks for the response&lt;BR /&gt;
&lt;BR /&gt;
but output for sample data should look like this&lt;BR /&gt;
&lt;BR /&gt;
xyz 123 02/11/2009    03/11/2009&lt;BR /&gt;
xyz 123 03/11/2009    04/11/2009&lt;BR /&gt;
xyz 123 04/11/2009    05/11/2009&lt;BR /&gt;
xyz 123 05/11/2009    &lt;BR /&gt;
abc 124 05/11/2009     &lt;BR /&gt;
def 125 02/11/2009      03/11/2009&lt;BR /&gt;
def 125 03/11/2009      .&lt;BR /&gt;
&lt;BR /&gt;
but if i execute the code first date is comming as missing..and also remaining coloums it is calculating wrong....can u pls suggest me what changes i have to make?&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
sasg</description>
      <pubDate>Sun, 19 Jun 2011 06:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16707#M2357</guid>
      <dc:creator>sasg</dc:creator>
      <dc:date>2011-06-19T06:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16708#M2358</link>
      <description>You can try the look ahead ability,&lt;BR /&gt;
For example:&lt;BR /&gt;
&lt;BR /&gt;
data aaa;&lt;BR /&gt;
format date ddmmyy10.;&lt;BR /&gt;
input company $ id date ddmmyy10.;&lt;BR /&gt;
cards;&lt;BR /&gt;
xyz 123 02/11/2009&lt;BR /&gt;
xyz 123 03/11/2009&lt;BR /&gt;
xyz 123 04/11/2009&lt;BR /&gt;
xyz 123 05/11/2009&lt;BR /&gt;
abc 124 05/11/2009&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=aaa;&lt;BR /&gt;
by company date;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
data bbb;  &lt;BR /&gt;
set aaa end=eof;  &lt;BR /&gt;
by company;  &lt;BR /&gt;
if not eof then &lt;BR /&gt;
   set aaa(firstobs=2 keep=date rename=date=date_after); &lt;BR /&gt;
if first.company and last.company then date_after=date; &lt;BR /&gt;
if eof then date_after=.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Although using the lag function techniques as the other here suggest should work fine....</description>
      <pubDate>Sun, 19 Jun 2011 11:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16708#M2358</guid>
      <dc:creator>yonib</dc:creator>
      <dc:date>2011-06-19T11:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16709#M2359</link>
      <description>Then use Merge Skill.&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data start;&lt;BR /&gt;
input Text:$3. ID:3. Date:mmddyy10.;&lt;BR /&gt;
format date mmddyy10.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
xyz 123 02/11/2009&lt;BR /&gt;
xyz 123 03/11/2009&lt;BR /&gt;
xyz 123 04/11/2009&lt;BR /&gt;
xyz 123 05/11/2009&lt;BR /&gt;
abc 124 05/11/2009&lt;BR /&gt;
def 125 02/11/2009&lt;BR /&gt;
def 125 03/11/2009&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data want;&lt;BR /&gt;
 merge start start(keep=id date rename=(id=_id date=_date) firstobs=2);&lt;BR /&gt;
 date1=ifn(id=_id,_date,.);&lt;BR /&gt;
 format date1 mmddyy10.;&lt;BR /&gt;
 drop _:;&lt;BR /&gt;
run; &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 20 Jun 2011 07:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16709#M2359</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-20T07:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16710#M2360</link>
      <description>If i use this logic everything looks fine....but for first record it is comming as .,but it should be second records date.&lt;BR /&gt;
&lt;BR /&gt;
Thanks,&lt;BR /&gt;
sasg</description>
      <pubDate>Mon, 20 Jun 2011 18:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16710#M2360</guid>
      <dc:creator>sasg</dc:creator>
      <dc:date>2011-06-20T18:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16711#M2361</link>
      <description>I copied the code from my previous post, pasted it into a SAS9.2 editor window running on Windows 7 64bit, then submitted the code.  The final output looks like this:&lt;BR /&gt;
&lt;BR /&gt;
xyz 123 02/11/2009 03/11/2009 &lt;BR /&gt;
xyz 123 03/11/2009 04/11/2009 &lt;BR /&gt;
xyz 123 04/11/2009 05/11/2009 &lt;BR /&gt;
xyz 123 05/11/2009 . &lt;BR /&gt;
abc 124 05/11/2009 . &lt;BR /&gt;
def 125 02/11/2009 03/11/2009 &lt;BR /&gt;
def 125 03/11/2009 . &lt;BR /&gt;
&lt;BR /&gt;
To me, this appears to be the output you want.  I'm having difficulty understanding why your results are not identical. Did you execute the final sort step? If not, the obs are in reverse order, and the "first"record will be missing date2. &lt;BR /&gt;
&lt;BR /&gt;
Please run a PROC PRINT on your final data set and paste the results here so we can compare and troubleshoot further.</description>
      <pubDate>Tue, 21 Jun 2011 01:50:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16711#M2361</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2011-06-21T01:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16712#M2362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have issue with this....different company&amp;nbsp; is having same id ....in that scenario i'm getting error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; how can i handle that one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; my code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;data bbb;&amp;nbsp; &lt;/P&gt;&lt;P&gt;set aaa end=eof;&amp;nbsp; &lt;/P&gt;&lt;P&gt;by company;&amp;nbsp; &lt;/P&gt;&lt;P&gt;if not eof then &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set aaa(firstobs=2 keep=date rename=date=date_after); &lt;/P&gt;&lt;P&gt;if first.company and last.company then date_after=date; &lt;/P&gt;&lt;P&gt;if last.company then date_after=.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;example scenario:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;company&amp;nbsp;&amp;nbsp;&amp;nbsp; id&amp;nbsp;&amp;nbsp; date&lt;/P&gt;&lt;P&gt;xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp; 02/11/2009&lt;/P&gt;&lt;P&gt;xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp; 03/11/2009&lt;/P&gt;&lt;P&gt;abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp; 05/11/2009&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;output should be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;company&amp;nbsp;&amp;nbsp;&amp;nbsp; id&amp;nbsp;&amp;nbsp; date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; next_date&lt;/P&gt;&lt;P&gt;xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp; 02/11/2009&amp;nbsp;&amp;nbsp;&amp;nbsp; 03/11/2009&lt;/P&gt;&lt;P&gt;xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp; 03/11/2009&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp; 05/11/2009&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;current output:&lt;/P&gt;&lt;P&gt;company&amp;nbsp;&amp;nbsp;&amp;nbsp; id&amp;nbsp;&amp;nbsp; date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; next_date&lt;/P&gt;&lt;P&gt;xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp; 02/11/2009&amp;nbsp;&amp;nbsp;&amp;nbsp; 03/11/2009&lt;/P&gt;&lt;P&gt;xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp; 03/11/2009&amp;nbsp;&amp;nbsp;&amp;nbsp; 05/11/2009&lt;/P&gt;&lt;P&gt;abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp;&amp;nbsp; 05/11/2009&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;rk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2011 22:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16712#M2362</guid>
      <dc:creator>sasg</dc:creator>
      <dc:date>2011-08-01T22:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16713#M2363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you've already been offered a number of ways to do this but, since you asked, how about:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data aaa; &lt;/P&gt;&lt;P&gt;&amp;nbsp; input company $ id&amp;nbsp;&amp;nbsp; date mmddyy8.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp; 02/11/2009&lt;/P&gt;&lt;P&gt;xyz&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp; 03/11/2009&lt;/P&gt;&lt;P&gt;abc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 123&amp;nbsp; 05/11/2009&lt;/P&gt;&lt;P&gt;bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 124&amp;nbsp; 01/12/2010&lt;/P&gt;&lt;P&gt;bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 124&amp;nbsp; 01/13/2010&lt;/P&gt;&lt;P&gt;bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 124&amp;nbsp; 01/14/2010&lt;/P&gt;&lt;P&gt;bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 124&amp;nbsp; 01/15/2010&lt;/P&gt;&lt;P&gt;bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 124&amp;nbsp; 01/16/2010&lt;/P&gt;&lt;P&gt;bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 124&amp;nbsp; 01/13/2010&lt;/P&gt;&lt;P&gt;bbb&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 124&amp;nbsp; 01/14/2010&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=aaa;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by company id descending date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data bbb (drop=date_after);&lt;/P&gt;&lt;P&gt;&amp;nbsp; set aaa;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by company id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain date_after;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format next_date date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.id then call missing(next_date);&lt;/P&gt;&lt;P&gt;&amp;nbsp; else next_date=date_after;; &lt;/P&gt;&lt;P&gt;&amp;nbsp; date_after=date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=bbb;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by company id date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2011 00:30:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16713#M2363</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-08-02T00:30:53Z</dc:date>
    </item>
    <item>
      <title>compare colums to create new coloum</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16714#M2364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;See &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://www.sascommunity.org/wiki/Look-Ahead_and_Look-Back"&gt;http://www.sascommunity.org/wiki/Look-Ahead_and_Look-Back&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2011 01:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-colums-to-create-new-coloum/m-p/16714#M2364</guid>
      <dc:creator>Howles</dc:creator>
      <dc:date>2011-08-02T01:46:46Z</dc:date>
    </item>
  </channel>
</rss>

