<?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: Standard Phone numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877321#M346597</link>
    <description>&lt;P&gt;Nobody knows Junior Samples' phone number.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 May 2023 17:18:20 GMT</pubDate>
    <dc:creator>HB</dc:creator>
    <dc:date>2023-05-24T17:18:20Z</dc:date>
    <item>
      <title>Standard Phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877239#M346555</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data phone_number;
input Phone_Number $ 15.;
standard_phone = catx('-', SUBSTR(PUT(phone_number, Z10.), 1, 3), SUBSTR(PUT(phone_number, Z10.), 4, 2), SUBSTR(PUT(phone_number, Z10.), 6, 4));
datalines;
123-545-5421
1236439775
7066950392
123-543-2345
8766783469
304-762-2467
 
8766783469
Na
123-545-5421
 
7066950392
123-543-2345
8766783469
304-762-2467
123-545-5421
1236439775
7066950392
Na
8766783469
8766783469
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here i want to clean the data and standard format for phone numbers in the above data&lt;/P&gt;
&lt;P&gt;i want miniplates all&amp;nbsp; phone numbers below format&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;123-543-2345&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;and&amp;nbsp;also&amp;nbsp;count&amp;nbsp;of&amp;nbsp;each&amp;nbsp;format&amp;nbsp;like&amp;nbsp;below&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;123-543-2345 totalcount=7&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;8766783469&amp;nbsp;totalcount=11&lt;/CODE&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Na total count=2&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 10:13:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877239#M346555</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-24T10:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: Standard Phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877244#M346559</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data phone_number;
input Phone_Number $ 15.;
datalines;
123-545-5421
1236439775
7066950392
123-543-2345
8766783469
304-762-2467
 
8766783469
Na
123-545-5421
 
7066950392
123-543-2345
8766783469
304-762-2467
123-545-5421
1236439775
7066950392
Na
8766783469
8766783469
;

data want;
    /* Create variable named TYPE for counting purposes */
    length type $ 8;
    set phone_number;
    is_dash=find(phone_number,'-');
    if is_dash=0 and upcase(phone_number)^='NA' and not missing(phone_number) then do;
        phone_number=cats(substr(phone_number,1,3),'-',substr(phone_number,4,3),'-',substr(phone_number,7));
        type='No Dash';
    end;
    else if upcase(phone_number)='NA' then type='NA';
    else if not missing(phone_number) then type='Dash';
run;

proc freq data=want;
    tables type;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 May 2023 11:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877244#M346559</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-24T11:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: Standard Phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877248#M346562</link>
      <description>&lt;P&gt;hi Miller&lt;/P&gt;
&lt;P&gt;Thank You for solution&lt;/P&gt;
&lt;P&gt;why you used upcase function for phone_number ?&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 11:48:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877248#M346562</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-24T11:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Standard Phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877250#M346563</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;hi Miller&lt;/P&gt;
&lt;P&gt;Thank You for solution&lt;/P&gt;
&lt;P&gt;why you used upcase function for phone_number ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;perhaps someone types it as NA one time and Na another time and na another time&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 11:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877250#M346563</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-24T11:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Standard Phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877252#M346565</link>
      <description>&lt;P&gt;Brilliant&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":hugging_face:"&gt;🤗&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 11:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877252#M346565</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-05-24T11:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Standard Phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877254#M346566</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data phone_number;
input Phone_Number $ 15.;
datalines;
123-545-5421
1236439775
7066950392
123-543-2345
8766783469
304-762-2467
 
8766783469
Na
123-545-5421
 
7066950392
123-543-2345
8766783469
304-762-2467
123-545-5421
1236439775
7066950392
Na
8766783469
8766783469
;

proc format;
picture fmt
low-high='000-000-0000'
.=' ';
run;

data want;
 set phone_number;
 new_phone_number=coalescec(put(input(compress(phone_number,,'kd'),best32.),fmt.),Phone_Number);
run;

proc freq data=want ;
    tables new_phone_number/missing;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1684929529570.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84241i062C4F8B593DA272/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1684929529570.png" alt="Ksharp_0-1684929529570.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 11:58:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877254#M346566</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-05-24T11:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Standard Phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877283#M346575</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;hi Miller&lt;/P&gt;
&lt;P&gt;Thank You for solution&lt;/P&gt;
&lt;P&gt;why you used upcase function for phone_number ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;BR549&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe not as common as it used to be but there are letters associated with certain digits of phone numbers. B is 2 (along with A and C) , R is 7 (along with P Q and S). Some organizations pay big money to have a number that "spells" something useful to them.&lt;/P&gt;
&lt;P&gt;So you may want to consider that as part of whatever purpose this has.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember, if you aren't doing arithmetic with it then it is not a number just a collection of digits.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 14:39:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877283#M346575</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-24T14:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Standard Phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877321#M346597</link>
      <description>&lt;P&gt;Nobody knows Junior Samples' phone number.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 17:18:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Standard-Phone-numbers/m-p/877321#M346597</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2023-05-24T17:18:20Z</dc:date>
    </item>
  </channel>
</rss>

