<?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: How to work with both Char and Numeric Data Types when manipulating phone numbers in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125504#M34492</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It turns out the CASE statement doesn't work because COMPRESS requires a char expression (even if it's not executed).&amp;nbsp; And there are formatting issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any way around this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to get COMPRESS to work for both char and numeric values?&amp;nbsp; Or is there anyway to convert any data type to a char, even if it is already a char?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To sum up, say I have two files where the phone numbers are different data types:&lt;/P&gt;&lt;P&gt;File 1 phone number:&amp;nbsp; 1234567890&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (data type numeric)&lt;/P&gt;&lt;P&gt;File 2 phone number:&amp;nbsp; 123-456-7890&amp;nbsp;&amp;nbsp; (data type char)&lt;/P&gt;&lt;P&gt;For both, the output needs to be 1234567890&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Mar 2013 23:44:33 GMT</pubDate>
    <dc:creator>Louis44</dc:creator>
    <dc:date>2013-03-01T23:44:33Z</dc:date>
    <item>
      <title>How to work with both Char and Numeric Data Types when manipulating phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125502#M34490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I import many different data files into SAS.&amp;nbsp; Some of the phone numbers have dashes, some do not.&amp;nbsp; How can I remove the dashes from the phone numbers for all different data types?&amp;nbsp; I get an error when I use COMPRESS on numeric data types.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I would like to do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table test as &lt;BR /&gt;select&lt;/P&gt;&lt;P&gt;COMPRESS(phone_number,'-') as PhoneNumber&lt;/P&gt;&lt;P&gt;from MyTable&lt;BR /&gt;;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this won't work when there isn't already a dash, because it's numeric.&amp;nbsp; I tried converting it to a char first, but if the phone number is already a char, I can't do that either.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't found a good way to check if a field is numeric or char value yet, either.&amp;nbsp; Otherwise something like this would work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select&lt;/P&gt;&lt;P&gt;case when ISNUMERIC(phone_number) then phone_number else COMPRESS(phone_number,'-') end as PhoneNumber&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But obviously ISNUMERIC does not exist.&amp;nbsp; Any ideas?&amp;nbsp; Thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2013 22:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125502#M34490</guid>
      <dc:creator>Louis44</dc:creator>
      <dc:date>2013-03-01T22:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to work with both Char and Numeric Data Types when manipulating phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125503#M34491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;VTYPE function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2013 22:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125503#M34491</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-01T22:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to work with both Char and Numeric Data Types when manipulating phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125504#M34492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It turns out the CASE statement doesn't work because COMPRESS requires a char expression (even if it's not executed).&amp;nbsp; And there are formatting issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any way around this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to get COMPRESS to work for both char and numeric values?&amp;nbsp; Or is there anyway to convert any data type to a char, even if it is already a char?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To sum up, say I have two files where the phone numbers are different data types:&lt;/P&gt;&lt;P&gt;File 1 phone number:&amp;nbsp; 1234567890&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (data type numeric)&lt;/P&gt;&lt;P&gt;File 2 phone number:&amp;nbsp; 123-456-7890&amp;nbsp;&amp;nbsp; (data type char)&lt;/P&gt;&lt;P&gt;For both, the output needs to be 1234567890&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2013 23:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125504#M34492</guid>
      <dc:creator>Louis44</dc:creator>
      <dc:date>2013-03-01T23:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to work with both Char and Numeric Data Types when manipulating phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125505#M34493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Step 1 - Convert all to characters&lt;/P&gt;&lt;P&gt;Step 2 - Compress out anything that's not numbers&lt;/P&gt;&lt;P&gt;Step 3 - Format as character.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 00:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125505#M34493</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-02T00:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to work with both Char and Numeric Data Types when manipulating phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125506#M34494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When converting all to characters (step 1 above), should I use PUT?&amp;nbsp; Because PUT does not work with a value that's already char datatype.&amp;nbsp; I tried to convert the field to char in a separate data step, but when I got to the proc sql, it thought it was numeric again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 00:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125506#M34494</guid>
      <dc:creator>Louis44</dc:creator>
      <dc:date>2013-03-02T00:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to work with both Char and Numeric Data Types when manipulating phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125507#M34495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think we, or at least I, need some more info on what your trying to do and what code you're using.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 02:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125507#M34495</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-03-02T02:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to work with both Char and Numeric Data Types when manipulating phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125508#M34496</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use CATS() function. It will handle both character and numeric arguments without issuing warnings.&amp;nbsp; You might want to set a length of your new variable, otherwise it will probably default to 200.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;COMPRESS(cats(phone_number),'-') as PhoneNumber length=10&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 02 Mar 2013 04:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125508#M34496</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-03-02T04:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to work with both Char and Numeric Data Types when manipulating phone numbers</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125509#M34497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;CATS works perfectly!&amp;nbsp; That's exactly what I needed, it works on both sets of data.&amp;nbsp; Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Mar 2013 17:52:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-work-with-both-Char-and-Numeric-Data-Types-when/m-p/125509#M34497</guid>
      <dc:creator>Louis44</dc:creator>
      <dc:date>2013-03-04T17:52:03Z</dc:date>
    </item>
  </channel>
</rss>

