<?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 character values in consecutive rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213316#M39393</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Post some test data in the form of a datastep, with required output.&amp;nbsp; At a guess, merging, hash, retain/lag, transposing, are all options you could use.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jul 2015 13:06:46 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-07-29T13:06:46Z</dc:date>
    <item>
      <title>compare character values in consecutive rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213315#M39392</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;I have multiple character values in a variable and want to compare each single row with other.&lt;/P&gt;&lt;P&gt;Can anyone please help me?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;USP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 12:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213315#M39392</guid>
      <dc:creator>USP2405</dc:creator>
      <dc:date>2015-07-29T12:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: compare character values in consecutive rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213316#M39393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Post some test data in the form of a datastep, with required output.&amp;nbsp; At a guess, merging, hash, retain/lag, transposing, are all options you could use.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 13:06:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213316#M39393</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-29T13:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: compare character values in consecutive rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213317#M39394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume you mean you want to compare a variable in each row with the same variable in every other row.&amp;nbsp; Assuming you don't have an enormous number of rows in your input set, you could perform an Cartesian product (cross join).&amp;nbsp; Keep in mind this will create a table with count of rows = original count of rows ^ 2, which can quickly become unwieldy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table analysis as&lt;/P&gt;&lt;P&gt;select a.*, &amp;lt;compare code&amp;gt;&lt;/P&gt;&lt;P&gt;from have a cross join have b;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 13:08:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213317#M39394</guid>
      <dc:creator>Sonywell</dc:creator>
      <dc:date>2015-07-29T13:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: compare character values in consecutive rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213318#M39395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have this sample data:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data new ;&lt;/P&gt;&lt;P&gt;input y $ @@;&lt;/P&gt;&lt;P&gt;datalines ;&lt;/P&gt;&lt;P&gt;mostthat morethis morethis morelike mostlike &lt;SPAN style="font-size: 13.3333330154419px;"&gt;morelike &lt;/SPAN&gt;morelike morelike mostlike&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to create a new column which will identify difference of each row.&lt;/P&gt;&lt;P&gt;for e.g. 2nd row is not simillar to 1st but 3rd is simillar to 2nd.&lt;/P&gt;&lt;P&gt;same way 7th is simillar to 6th and 8th is to 7th.but 9th is not simillar to 8th row.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 13:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213318#M39395</guid>
      <dc:creator>USP2405</dc:creator>
      <dc:date>2015-07-29T13:43:02Z</dc:date>
    </item>
    <item>
      <title>Re: compare character values in consecutive rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213319#M39396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are only concerned with consecutive records this will work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data have;&lt;/P&gt;&lt;P&gt;input y $ @@;&lt;/P&gt;&lt;P&gt;datalines ;&lt;/P&gt;&lt;P&gt;mostthat morethis morethis morelike mostlike morelike morelike morelike mostlike&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;l_y = lag(y);&lt;/P&gt;&lt;P&gt;if l_y = y then flag = 'Same';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else flag = 'Diff';&lt;/P&gt;&lt;P&gt;drop l_y;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 14:06:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213319#M39396</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-07-29T14:06:58Z</dc:date>
    </item>
    <item>
      <title>Re: compare character values in consecutive rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213320#M39397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, its still not clear your logic.&amp;nbsp; If you want to know which ones appear in more than one row, then thats simple aggregate:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select&amp;nbsp; A.*,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B.CNT&lt;/P&gt;&lt;P&gt;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; WORK.NEW A&lt;/P&gt;&lt;P&gt;&amp;nbsp; left join (select Y,count(Y) as CNT from WORK.NEW group by Y) B&lt;/P&gt;&lt;P&gt;&amp;nbsp; on&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A.Y=B.Y;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, what do you mean by similar?&amp;nbsp; Do you need soundex() function or something.&amp;nbsp; What about identifiers, is there grouping involved.&amp;nbsp; If you need to find out if one element appears and what specific row it appears on then use monotonic() or assign a variable for _n_, then use this to merge, ie.&lt;/P&gt;&lt;P&gt;from HAVE A&lt;/P&gt;&lt;P&gt;left join (select * from HAVE where Y=A.Y and ID &amp;gt; A.ID) B&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 14:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213320#M39397</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-29T14:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: compare character values in consecutive rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213321#M39398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Mark.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 12:33:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213321#M39398</guid>
      <dc:creator>USP2405</dc:creator>
      <dc:date>2015-07-31T12:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: compare character values in consecutive rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213322#M39399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Jul 2015 12:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/compare-character-values-in-consecutive-rows/m-p/213322#M39399</guid>
      <dc:creator>USP2405</dc:creator>
      <dc:date>2015-07-31T12:35:16Z</dc:date>
    </item>
  </channel>
</rss>

