<?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: String Difference in Percentage in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167758#M43448</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Jul 2014 19:39:32 GMT</pubDate>
    <dc:creator>JAR</dc:creator>
    <dc:date>2014-07-08T19:39:32Z</dc:date>
    <item>
      <title>String Difference in Percentage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167754#M43444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;I would like to learn how to calculate % change, when two strings are compared. &lt;/P&gt;&lt;P&gt;Here is the original file:&lt;/P&gt;&lt;TABLE cellpadding="5" cellspacing="0" class="table" frame="box" rules="all" summary="Procedure Print: Data Set WORK.HAVE"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;&lt;TD class="l data"&gt;RAT&lt;/TD&gt;&lt;TD class="l data"&gt;CAT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;&lt;TD class="l data"&gt;BELL&lt;/TD&gt;&lt;TD class="l data"&gt;BALL&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;3&lt;/TH&gt;&lt;TD class="l data"&gt;TIME&lt;/TD&gt;&lt;TD class="l data"&gt;TOM&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As there is only one character that is different in the first observation, it should return 1/3 %(number of deviation / total number of char in the original). &lt;/P&gt;&lt;P&gt;Desired output is something like this:&lt;/P&gt;&lt;TABLE cellpadding="5" cellspacing="0" class="table" frame="box" rules="all" summary="Procedure Print: Data Set WORK.WANT"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;&lt;TD class="l data"&gt;RAT&lt;/TD&gt;&lt;TD class="l data"&gt;CAT&lt;/TD&gt;&lt;TD class="r data"&gt;33&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;&lt;TD class="l data"&gt;BELL&lt;/TD&gt;&lt;TD class="l data"&gt;BALL&lt;/TD&gt;&lt;TD class="r data"&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TH class="r rowheader" scope="row"&gt;3&lt;/TH&gt;&lt;TD class="l data"&gt;TIME&lt;/TD&gt;&lt;TD class="l data"&gt;TOM&lt;/TD&gt;&lt;TD class="r data"&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jijil Ramakrishnan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Jul 2014 17:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167754#M43444</guid>
      <dc:creator>JAR</dc:creator>
      <dc:date>2014-07-06T17:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: String Difference in Percentage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167755#M43445</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this for the desired output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input obs var1 $ var2 $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 RAT CAT&lt;BR /&gt;2 BELL BALL&lt;BR /&gt;3 TIME TOM&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;/P&gt;&lt;P&gt;do i=1 by 1 while(substr(var1,i,1) ne ' ');&lt;BR /&gt;if index(var2,substr(var1,i,1))&amp;gt;0 then cnt+1;&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;cnt=0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data final (drop=i cnt);&lt;BR /&gt;set want;&lt;BR /&gt;by obs;&lt;BR /&gt;if last.obs;&lt;BR /&gt;diff=(i-cnt)/i*100;&lt;BR /&gt;format diff 8.0;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Jul 2014 18:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167755#M43445</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-07-06T18:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: String Difference in Percentage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167756#M43446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Approximate matches between strings is an already well researched topic. SAS provides you with many tools in that area. Please look at SAS functions COMPGED, COMPLEV, SOUNDEX, and SPEDIS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Jul 2014 19:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167756#M43446</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2014-07-06T19:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: String Difference in Percentage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167757#M43447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 19:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167757#M43447</guid>
      <dc:creator>JAR</dc:creator>
      <dc:date>2014-07-08T19:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: String Difference in Percentage</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167758#M43448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jul 2014 19:39:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/String-Difference-in-Percentage/m-p/167758#M43448</guid>
      <dc:creator>JAR</dc:creator>
      <dc:date>2014-07-08T19:39:32Z</dc:date>
    </item>
  </channel>
</rss>

