<?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 read raw data file with &amp;quot;,&amp;quot; delimiter with dollar symbol numeric data values? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638585#M21581</link>
    <description>&lt;P&gt;thank you. The code worked out perfectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the scenario where this value $1,456,568 is not the last one in the row, how do we solve that?&lt;/P&gt;</description>
    <pubDate>Thu, 09 Apr 2020 05:10:08 GMT</pubDate>
    <dc:creator>vijayasri</dc:creator>
    <dc:date>2020-04-09T05:10:08Z</dc:date>
    <item>
      <title>how to read raw data file with "," delimiter with dollar symbol numeric data values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638483#M21570</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to read raw data file which is .txt file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Frankfurt,Freight,Direct,$1,464,938&lt;BR /&gt;Frankfurt,Freight,Indirect,$198,942&lt;BR /&gt;Frankfurt,Freight,Other,$144,685&lt;BR /&gt;Frankfurt,Other,Direct,$111,193&lt;BR /&gt;Frankfurt,Other,Indirect,$12,057&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Frankfurt,Other,Other,$10,717&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm tried the below syntax:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data revenue;
infile "file-path/file.txt" dlm=",";
input City $ Transport $ Type $ Amount:dollar12.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;my output is&lt;/P&gt;&lt;P&gt;City&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Transport&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Type&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Amount&lt;/P&gt;&lt;P&gt;Frankfur&amp;nbsp; &amp;nbsp; Freight&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Direct&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;Frankfur&amp;nbsp; &amp;nbsp; Freight&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Indirect&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;198&lt;BR /&gt;Frankfur&amp;nbsp; &amp;nbsp; Freight&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Other&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 144&lt;BR /&gt;Frankfur&amp;nbsp; &amp;nbsp; Other&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Direct&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;111&lt;BR /&gt;Frankfur&amp;nbsp; &amp;nbsp; Other&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Indirect&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&lt;BR /&gt;Frankfur&amp;nbsp; &amp;nbsp; Other&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Other&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, in the amount variable data values are displayed wrongly.&lt;/P&gt;&lt;P&gt;for the value&amp;nbsp;$1,464,938 the numbers after first comma are missing in my output. How to overcome this? if there is delimiter in the same variable how to write the syntax for that?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Apr 2020 20:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638483#M21570</guid>
      <dc:creator>vijayasri</dc:creator>
      <dc:date>2020-04-08T20:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to read raw data file with "," delimiter with dollar symbol numeric data values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638496#M21573</link>
      <description>&lt;P&gt;Did you open a CSV in Excel or other spread sheet? That sometimes corrupts values and may have removed quotes from around the currency amounts.&lt;/P&gt;
&lt;P&gt;I would expect a proper CSV with dollar amounts to appear as&lt;/P&gt;
&lt;PRE&gt;Frankfurt,Freight,Direct,"$1,464,938"
Frankfurt,Freight,Indirect,"$198,942"&lt;/PRE&gt;
&lt;P&gt;which would call for the use of the DSD (delimiter sensitive data) option on the INFILE statement. But that will expect the commas to appear inside quoted values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data revenue;
infile datalines dlm="," dsd;
input City $ Transport $ Type $ Amount:dollar12.;
datalines;
Frankfurt,Freight,Direct,"$1,464,938"
Frankfurt,Freight,Indirect,"$198,942"
;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Apr 2020 21:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638496#M21573</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-08T21:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: how to read raw data file with "," delimiter with dollar symbol numeric data values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638556#M21580</link>
      <description>&lt;P&gt;Hopefully you can contact the creator of the file and ask them to make one that is in a valid format.&amp;nbsp; Values that contain delimiters need to be quoted.&lt;/P&gt;
&lt;PRE&gt;Frankfurt,Freight,Direct,"$1,464,938"
Frankfurt,Freight,Indirect,"$198,942"&lt;/PRE&gt;
&lt;P&gt;If this is only happening in the last field then you can use FORMATTED input for that field and SAS will read right through the delimiters.&amp;nbsp; (That will not work if there are other fields after it though as it will go ahead and try to read the characters from the next field also.)&amp;nbsp; So remove the colon modifier in front of the in-line informat in your INPUT statement. That is telling SAS to read that field using LIST MODE instead of FORMATTED mode (even though you have specified and informat).&amp;nbsp; Note there is no need to use DOLLAR as the informat name. That is just an alias for the COMMA informat.&amp;nbsp; There is no need to limit the width to 12 bytes.&amp;nbsp; Just go ahead and use the maximum 32 bytes.&amp;nbsp; Make sure to add the TRUNCOVER option on the INFILE statement instead of the old style MISSOVER option so that SAS does not discard the last value if it is shorter than the width of the informat.&amp;nbsp; While you are at make sure to give SAS some indication that your three character variables might need be longer than the default of 8 bytes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data revenue;
  infile "file-path/file.txt" dlm="," truncover;
  input City :$20. Transport :$20. Type :$20. Amount comma32.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 02:56:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638556#M21580</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-09T02:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to read raw data file with "," delimiter with dollar symbol numeric data values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638585#M21581</link>
      <description>&lt;P&gt;thank you. The code worked out perfectly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the scenario where this value $1,456,568 is not the last one in the row, how do we solve that?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 05:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638585#M21581</guid>
      <dc:creator>vijayasri</dc:creator>
      <dc:date>2020-04-09T05:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: how to read raw data file with "," delimiter with dollar symbol numeric data values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638586#M21582</link>
      <description>&lt;P&gt;Hello, thanks for the quick reply. however I used "dsd" option but it did not work out for me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And to ans your question, no I did not open the file in any other format. I got the file as is.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 05:12:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638586#M21582</guid>
      <dc:creator>vijayasri</dc:creator>
      <dc:date>2020-04-09T05:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to read raw data file with "," delimiter with dollar symbol numeric data values?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638653#M21588</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/305650"&gt;@vijayasri&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;thank you. The code worked out perfectly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the scenario where this value $1,456,568 is not the last one in the row, how do we solve that?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The best way is to return the file to the source and request that they send a new on in a format that can be scanned.&lt;/P&gt;
&lt;P&gt;If you are forced to deal with a file that cannot be re-created you might be able to handle a file that has one field in the middle by counting the number of commas from both ends.&amp;nbsp; So pick off the fields in front and the fields after and then whatever is left is your field with the embedded commas.&amp;nbsp; If there are two such fields in the same line then that is not always possible.&amp;nbsp; In that case you might need to use specific knowledge of what types of values are valid for the field and/or the fields next to it.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 12:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/how-to-read-raw-data-file-with-quot-quot-delimiter-with-dollar/m-p/638653#M21588</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-09T12:42:32Z</dc:date>
    </item>
  </channel>
</rss>

