<?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: Comparing rows in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43226#M11274</link>
    <description>Hello Rsva,&lt;BR /&gt;
&lt;BR /&gt;
If I understood you correctly then this is a solution:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
input Id $ DOB State $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
xx1 20061023 GA&lt;BR /&gt;
xx1 20080115 GA&lt;BR /&gt;
sd45 20050203 FL&lt;BR /&gt;
sd45 20050203 FL&lt;BR /&gt;
h5g 20060709 NV&lt;BR /&gt;
h5g 20080115 NV&lt;BR /&gt;
7uj 20071026 CA&lt;BR /&gt;
7uj 20071026 CA&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=i;&lt;BR /&gt;
  by ID DOB;&lt;BR /&gt;
run;&lt;BR /&gt;
data r;&lt;BR /&gt;
  set i;&lt;BR /&gt;
  if First.DOB=LAST.DOB                   then code=2;&lt;BR /&gt;
  if NOT (First.DOB = 1 and Last.DOB = 1) then code=1; &lt;BR /&gt;
  by ID DOB;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
    <pubDate>Thu, 02 Dec 2010 15:45:58 GMT</pubDate>
    <dc:creator>SPR</dc:creator>
    <dc:date>2010-12-02T15:45:58Z</dc:date>
    <item>
      <title>Comparing rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43225#M11273</link>
      <description>I would like to compare a value between two rows. For e.g. I have duplicate id numbers in Column A, DOB in Column B, and state in Column C.&lt;BR /&gt;
Id	  DOB	                   State&lt;BR /&gt;
xx1	  20061023	    GA&lt;BR /&gt;
xx1	  20080115	    GA&lt;BR /&gt;
sd45	  20050203	    FL&lt;BR /&gt;
sd45	  20050203	    FL&lt;BR /&gt;
h5g	  20060709	   NV&lt;BR /&gt;
h5g	  20080115	   NV&lt;BR /&gt;
7uj	  20071026	   CA&lt;BR /&gt;
7uj	  20071026	   CA&lt;BR /&gt;
&lt;BR /&gt;
I want to check if DOB for the two (same) ids are same. If they are same I would like to code as 1 else code as 2.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance.</description>
      <pubDate>Thu, 02 Dec 2010 14:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43225#M11273</guid>
      <dc:creator>rsva</dc:creator>
      <dc:date>2010-12-02T14:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43226#M11274</link>
      <description>Hello Rsva,&lt;BR /&gt;
&lt;BR /&gt;
If I understood you correctly then this is a solution:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
input Id $ DOB State $;&lt;BR /&gt;
datalines;&lt;BR /&gt;
xx1 20061023 GA&lt;BR /&gt;
xx1 20080115 GA&lt;BR /&gt;
sd45 20050203 FL&lt;BR /&gt;
sd45 20050203 FL&lt;BR /&gt;
h5g 20060709 NV&lt;BR /&gt;
h5g 20080115 NV&lt;BR /&gt;
7uj 20071026 CA&lt;BR /&gt;
7uj 20071026 CA&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=i;&lt;BR /&gt;
  by ID DOB;&lt;BR /&gt;
run;&lt;BR /&gt;
data r;&lt;BR /&gt;
  set i;&lt;BR /&gt;
  if First.DOB=LAST.DOB                   then code=2;&lt;BR /&gt;
  if NOT (First.DOB = 1 and Last.DOB = 1) then code=1; &lt;BR /&gt;
  by ID DOB;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Thu, 02 Dec 2010 15:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43226#M11274</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-12-02T15:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43227#M11275</link>
      <description>Rsva&lt;BR /&gt;
what should happen if an ID has more than two rows?&lt;BR /&gt;
peterC</description>
      <pubDate>Thu, 02 Dec 2010 16:10:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43227#M11275</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-12-02T16:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43228#M11276</link>
      <description>Hello PeterC,&lt;BR /&gt;
&lt;BR /&gt;
My code is taking care of these cases too.&lt;BR /&gt;
&lt;BR /&gt;
SPR</description>
      <pubDate>Thu, 02 Dec 2010 16:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43228#M11276</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2010-12-02T16:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43229#M11277</link>
      <description>yes  but SPR, you are assuming that a trio(or more) should be handled the same as a pair.&lt;BR /&gt;
(making my own assumptions)&lt;BR /&gt;
what if the third child is not the same age as the twins within the family ID?&lt;BR /&gt;
hence, my question to the original poster</description>
      <pubDate>Thu, 02 Dec 2010 16:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43229#M11277</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2010-12-02T16:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43230#M11278</link>
      <description>Thanks SPR it worked perfectly.</description>
      <pubDate>Fri, 03 Dec 2010 15:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43230#M11278</guid>
      <dc:creator>rsva</dc:creator>
      <dc:date>2010-12-03T15:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing rows</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43231#M11279</link>
      <description>Thanks for your question Peter. I tried SPR's sample code and included third row for an id. It worked fine. When I added a third row, &lt;BR /&gt;
&lt;BR /&gt;
Case1 (Coded as 2)&lt;BR /&gt;
xx1   20061023   GA   2&lt;BR /&gt;
xx1   20080115   GA   2&lt;BR /&gt;
xx1   20100115   GA   2&lt;BR /&gt;
&lt;BR /&gt;
Case2 (Codes twin as 1 and the other as 2)&lt;BR /&gt;
sd45   20050203   FL   1&lt;BR /&gt;
sd45   20050203   FL   1&lt;BR /&gt;
sd45   20041023   FL   2&lt;BR /&gt;
&lt;BR /&gt;
This is what my expected result was. Sorry for not being clear in my question.&lt;BR /&gt;
&lt;BR /&gt;
Thanks a lot.</description>
      <pubDate>Fri, 03 Dec 2010 15:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-rows/m-p/43231#M11279</guid>
      <dc:creator>rsva</dc:creator>
      <dc:date>2010-12-03T15:08:14Z</dc:date>
    </item>
  </channel>
</rss>

