<?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 and Matching Character Variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-and-Matching-Character-Variables/m-p/47065#M12593</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, I have added one more variable 'num' to identify the original obs no., take it out as you wish.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input (x1-x4) (:$);&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;aa ab aa bd&lt;/P&gt;&lt;P&gt;dd cc dd cc&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=first second match num) ;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;array xx $ x1-x4;&lt;/P&gt;&lt;P&gt;do _i=1 to dim(xx);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do _j=_i+1 to dim(xx);&lt;/P&gt;&lt;P&gt; first=vname(xx(_i));&lt;/P&gt;&lt;P&gt; second=vname(xx(_j));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; xx(_i)=xx(_j) then&amp;nbsp;&amp;nbsp; match='Y';&lt;/P&gt;&lt;P&gt; else match='N';&lt;/P&gt;&lt;P&gt; Num=_n_;&lt;/P&gt;&lt;P&gt; output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Mar 2012 15:48:48 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-03-28T15:48:48Z</dc:date>
    <item>
      <title>Comparing and Matching Character Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-and-Matching-Character-Variables/m-p/47064#M12592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Say I have a data set with 4 character variables: x1-x4.&amp;nbsp; &lt;/P&gt;&lt;P&gt;The data looks something like: ab cd ab ca.&lt;/P&gt;&lt;P&gt;I want to compare each variable to the other. Therefore, I have 6 combinations. I am interested in the ones that match (i.e., x1 matches x3, 'ab'). &lt;/P&gt;&lt;P&gt;So my output should contain 3 columns: &lt;/P&gt;&lt;P&gt;First and second columns list the variables being compared to each other (total of 6 rows due to 6 combinations). &lt;/P&gt;&lt;P&gt;The third column stating whether or not there is a match. &lt;/P&gt;&lt;P&gt;I know to calculate the number of combinations, I use: c42=comb(4,2). &lt;/P&gt;&lt;P&gt;I am stuck thereafter. Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 14:51:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-and-Matching-Character-Variables/m-p/47064#M12592</guid>
      <dc:creator>Lien728</dc:creator>
      <dc:date>2012-03-28T14:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing and Matching Character Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-and-Matching-Character-Variables/m-p/47065#M12593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, I have added one more variable 'num' to identify the original obs no., take it out as you wish.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input (x1-x4) (:$);&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;aa ab aa bd&lt;/P&gt;&lt;P&gt;dd cc dd cc&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (keep=first second match num) ;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;array xx $ x1-x4;&lt;/P&gt;&lt;P&gt;do _i=1 to dim(xx);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do _j=_i+1 to dim(xx);&lt;/P&gt;&lt;P&gt; first=vname(xx(_i));&lt;/P&gt;&lt;P&gt; second=vname(xx(_j));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&amp;nbsp; xx(_i)=xx(_j) then&amp;nbsp;&amp;nbsp; match='Y';&lt;/P&gt;&lt;P&gt; else match='N';&lt;/P&gt;&lt;P&gt; Num=_n_;&lt;/P&gt;&lt;P&gt; output;&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 15:48:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-and-Matching-Character-Variables/m-p/47065#M12593</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-28T15:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing and Matching Character Variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Comparing-and-Matching-Character-Variables/m-p/47066#M12594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thank you very much! That helped a lot and it was very straightforward! I was able to tweak it and fit it to a more complicated data set. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 16:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Comparing-and-Matching-Character-Variables/m-p/47066#M12594</guid>
      <dc:creator>Lien728</dc:creator>
      <dc:date>2012-03-28T16:52:03Z</dc:date>
    </item>
  </channel>
</rss>

