<?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: ID var with leading 0s in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ID-var-with-leading-0s/m-p/216499#M39902</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Make SQL's join be more powerful by prxmatch . I am going to write a paper about it .Waiting ...................&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;input k $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;001&lt;/P&gt;&lt;P&gt;050&lt;/P&gt;&lt;P&gt;067&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data b;&lt;/P&gt;&lt;P&gt;input k $ flag;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 1&lt;/P&gt;&lt;P&gt;50 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt; select a.k,b.flag&lt;/P&gt;&lt;P&gt;&amp;nbsp; from a left join b on prxmatch(cats('/^0*',b.k,'/'),a.k);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 May 2015 14:16:29 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2015-05-18T14:16:29Z</dc:date>
    <item>
      <title>ID var with leading 0s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ID-var-with-leading-0s/m-p/216497#M39900</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 am trying to join two datasets on an ID variable present in both datasets. However, in one dataset, the ID is formatted to always be at least 3 digits by adding leading 0s if the ID is only a 1- or 2-digit number (so like 001, 050, 067, etc). In the other dataset, the ID variable does not have the leading 0s, and the same values that I used as examples before would be 1, 50, 67, etc. I'm not sure how to match on these values considering the mismatch. Trimming the 0s would be difficult because some IDs have two leading 0s, some one leading 0, and others zero leading 0s. Within each dataset, the IDs have different lengths (either 3 or 4). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 13:40:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ID-var-with-leading-0s/m-p/216497#M39900</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2015-05-18T13:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: ID var with leading 0s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ID-var-with-leading-0s/m-p/216498#M39901</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Personally I would convert the two to numeric for comparison:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table WANT as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; B.VAR&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; HAVE A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join&amp;nbsp;&amp;nbsp; ANOTHER_HAVE B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input(A.ID,best.)=input(B.ID,best.);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that it assumes both are character.&amp;nbsp; If they are number, or one or the other is number, no need to input it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 14:00:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ID-var-with-leading-0s/m-p/216498#M39901</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-05-18T14:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: ID var with leading 0s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ID-var-with-leading-0s/m-p/216499#M39902</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Make SQL's join be more powerful by prxmatch . I am going to write a paper about it .Waiting ...................&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;input k $;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;001&lt;/P&gt;&lt;P&gt;050&lt;/P&gt;&lt;P&gt;067&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data b;&lt;/P&gt;&lt;P&gt;input k $ flag;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1 1&lt;/P&gt;&lt;P&gt;50 2&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt; select a.k,b.flag&lt;/P&gt;&lt;P&gt;&amp;nbsp; from a left join b on prxmatch(cats('/^0*',b.k,'/'),a.k);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 14:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ID-var-with-leading-0s/m-p/216499#M39902</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-05-18T14:16:29Z</dc:date>
    </item>
  </channel>
</rss>

