<?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: Identifying correct length and format of postal codes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791426#M253492</link>
    <description>&lt;P&gt;&lt;A href="https://regex101.com/" target="_self"&gt;https://regex101.com/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.regular-expressions.info/tutorial.html" target="_self"&gt;https://www.regular-expressions.info/tutorial.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf" target="_self"&gt;https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jan 2022 13:56:14 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2022-01-21T13:56:14Z</dc:date>
    <item>
      <title>Identifying correct length and format of postal codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791272#M253414</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have over 17000 observations in a dataset and one of the Variables is postal_code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a dataset which has only the correct postal codes i.e K2C0J8.&lt;/P&gt;&lt;P&gt;the postal code should be six digits as in the example above, have no spaces, no special characters and the 2nd, 4th and the 6th spaces should be numbers and the first, third and fifth places alphabets.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my code so far:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data CORRECTPOSTAL NOPOSTAL;&lt;BR /&gt;set Y;&lt;BR /&gt;if length(compress(postal_code,"-/+~! )( "))=6 and PRXMATCH(PRXPARSE("/\w\d\w\d\w\d/i"),compress(postal_code,"- ")) then do;&lt;BR /&gt;POSTAL=compress(postal_code,"-/+~! )( ");&lt;BR /&gt;output CORRECTPOSTAL;&lt;BR /&gt;end;&lt;BR /&gt;else output NOPOSTAL;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this does the job alright but misses out on some observations and I dont know why.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 20:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791272#M253414</guid>
      <dc:creator>shahm</dc:creator>
      <dc:date>2022-01-20T20:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying correct length and format of postal codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791292#M253427</link>
      <description>&lt;P&gt;can you post sample data?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 21:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791292#M253427</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-01-20T21:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying correct length and format of postal codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791296#M253430</link>
      <description>&lt;P&gt;Post some examples of the values that don't return the correct result.&lt;/P&gt;
&lt;P&gt;If you both incorrect CORRECTPOSTAL and NOPOSTAL then some of each and which result you are getting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: It is a very good idea to post code in either a code or text box opened using the "running man" or &amp;lt;/&amp;gt; icon appearing above the message window. The forum main message windows will reformat pasted text and may result in code changes, which could be pretty significant when dealing with text manipulation code.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jan 2022 21:44:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791296#M253430</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-20T21:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying correct length and format of postal codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791332#M253449</link>
      <description>&lt;P&gt;you can do with one line only:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if prxmatch('/\b([a-zA-Z])\d([a-zA-Z])\d([a-zA-Z])\d\s/', postal_code);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="a1.png" style="width: 838px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67569i15255E6BD4C969A4/image-size/large?v=v2&amp;amp;px=999" role="button" title="a1.png" alt="a1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 00:44:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791332#M253449</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-01-21T00:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying correct length and format of postal codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791419#M253487</link>
      <description>&lt;P&gt;Thank you all for your prompt responses! My code did identify the missing and incorrect postal codes accurately. Any ideas where can I brush up my Regular expressions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;M&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 13:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791419#M253487</guid>
      <dc:creator>shahm</dc:creator>
      <dc:date>2022-01-21T13:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying correct length and format of postal codes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791426#M253492</link>
      <description>&lt;P&gt;&lt;A href="https://regex101.com/" target="_self"&gt;https://regex101.com/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.regular-expressions.info/tutorial.html" target="_self"&gt;https://www.regular-expressions.info/tutorial.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf" target="_self"&gt;https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jan 2022 13:56:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-correct-length-and-format-of-postal-codes/m-p/791426#M253492</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-01-21T13:56:14Z</dc:date>
    </item>
  </channel>
</rss>

