<?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: Importing Phone Numbers from a CSV File in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248616#M46712</link>
    <description>&lt;P&gt;You are very close. Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*This is how I am reading in the file into SAS*/
data phone;
infile '/sscc/home/m/mkh246/Textbook_Datasets/Listing of Phone.csv' dlm=',' firstobs=2 truncover;
length phone $16;
input phone &amp;amp;;
Run;
 
/*This is my data cleaning step I am practicing*/
data phoneformatted;
length PhoneNumber $10;
set work.phone;
PhoneNumber=compress(Phone, ' ()-.');
drop Phone;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Don't let SAS guess the length of your input field.The &amp;amp; in the input will allow single spaces in the input field. Add a space in the list of characters to compress.&lt;/P&gt;</description>
    <pubDate>Mon, 08 Feb 2016 03:32:11 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-02-08T03:32:11Z</dc:date>
    <item>
      <title>Importing Phone Numbers from a CSV File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248613#M46710</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am brand new to SAS so I have a basic question.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am practicing reading in CSV files into SAS using an infile statement, and then cleaning that data to make it into a standardized format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data I want to read into SAS is a list of phone numbers:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Raw Data Looks Like This:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Phone&amp;nbsp;&lt;/P&gt;&lt;P&gt;(908)232-4856&lt;/P&gt;&lt;P&gt;210.343.4757&lt;/P&gt;&lt;P&gt;(516) 343 - 9293&lt;/P&gt;&lt;P&gt;9342342345&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to import using the below program, but my problem is that the phone numbers are getting cut off at the dash (-) or the dot (.) or the blank. How do I read in everything properly? What I am I missing? Any help much appreciated. Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*This is how I am reading in the file into SAS*/&lt;BR /&gt;data phone;&lt;BR /&gt;infile '/sscc/home/m/mkh246/Textbook_Datasets/Listing of Phone.csv' dlm=',' firstobs=2 truncover;&lt;BR /&gt;input phone $;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*This is my data cleaning step I am practicing*/&lt;BR /&gt;data phoneformatted;&lt;BR /&gt;length PhoneNumber $10;&lt;BR /&gt;set work.phone;&lt;BR /&gt;PhoneNumber=compress(Phone,'()-.');&lt;BR /&gt;drop Phone;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 03:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248613#M46710</guid>
      <dc:creator>morgankho</dc:creator>
      <dc:date>2016-02-08T03:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Phone Numbers from a CSV File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248615#M46711</link>
      <description>&lt;P&gt;SAS strings by default are assigned a length of 8, unless you specify a longer length. You'll need to specify a longer length ahead of reading in the variable, an informat is a simple way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is your file actually CSV (comma separated)? The way presented it's shown as a single variable and then you may have to change how you read it in.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data phone;
Informat phone $20.;
infile '/sscc/home/m/mkh246/Textbook_Datasets/Listing of Phone.csv' dlm=',' firstobs=2 truncover;
input phone $;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 03:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248615#M46711</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-08T03:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Phone Numbers from a CSV File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248616#M46712</link>
      <description>&lt;P&gt;You are very close. Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*This is how I am reading in the file into SAS*/
data phone;
infile '/sscc/home/m/mkh246/Textbook_Datasets/Listing of Phone.csv' dlm=',' firstobs=2 truncover;
length phone $16;
input phone &amp;amp;;
Run;
 
/*This is my data cleaning step I am practicing*/
data phoneformatted;
length PhoneNumber $10;
set work.phone;
PhoneNumber=compress(Phone, ' ()-.');
drop Phone;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Don't let SAS guess the length of your input field.The &amp;amp; in the input will allow single spaces in the input field. Add a space in the list of characters to compress.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 03:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248616#M46712</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-02-08T03:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Phone Numbers from a CSV File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248617#M46713</link>
      <description>&lt;P&gt;Thank you PG! This worked!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see how the "&amp;amp;" works, but may I ask where does the $16 come from in the length? I am struggling a little bit wrapping my head around how the length part works exactly. If you could explain how that works that would be great!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 03:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248617#M46713</guid>
      <dc:creator>morgankho</dc:creator>
      <dc:date>2016-02-08T03:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Importing Phone Numbers from a CSV File</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248619#M46714</link>
      <description>&lt;P&gt;The length statement tells SAS what the length of the character variable should be, instead of letting SAS guessing (sometimes wrong) what it should be. The length statement should precede&amp;nbsp;the first mention of the variable in the data step. I used 16 but, of course, you could chose another length.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 04:05:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-Phone-Numbers-from-a-CSV-File/m-p/248619#M46714</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-02-08T04:05:21Z</dc:date>
    </item>
  </channel>
</rss>

