<?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: SAS Error in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Error/m-p/120076#M33065</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the problem is that SAS is confused because when no delimiter is specified for the infile statement, so the default is a space.&lt;/P&gt;&lt;P&gt;But on your input statement you've specified that for column A, it may contain a space by using the '&amp;amp;'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So how does SAS know if you mean a space in the value for column A or a space as a delimiter?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you specify a delimiter (except using a comma as you've also got a comma format being used for B) on the infile statement and also wrap column A's values with double quotes, this will get around this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA test;&lt;BR /&gt; infile datalines dlm='*' dsd;&lt;BR /&gt; input A &amp;amp; $15. B :comma14.;&lt;BR /&gt;datalines;&lt;BR /&gt;"chocolate cream"*10,453&lt;BR /&gt;"tofucutlet"*12,187&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data = test;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use a comma as a delimiter too, only if you wrap the comma formated number in quotes too making sure you use the DSD option.&lt;/P&gt;&lt;P&gt;DATA test;&lt;BR /&gt; infile datalines dlm=',' dsd;&lt;BR /&gt; input A &amp;amp; $15. B :comma14.;&lt;BR /&gt;datalines;&lt;BR /&gt;"chocolate cream","10,453"&lt;BR /&gt;"tofucutlet","12,187"&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data = test;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know I've changed the datalines but I'm not sure if there is another way? Hope this helps as a starting point.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Aug 2013 07:04:07 GMT</pubDate>
    <dc:creator>PaulLee</dc:creator>
    <dc:date>2013-08-23T07:04:07Z</dc:date>
    <item>
      <title>SAS Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Error/m-p/120075#M33064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using the code -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA test;&lt;/P&gt;&lt;P&gt;infile datalines;&lt;/P&gt;&lt;P&gt;input A &amp;amp; $14. B : comma14.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;chocolate cream 10,453&lt;/P&gt;&lt;P&gt;tofucutlet 12,187&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print data = test;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not know why I get the invalid data error when reading B as the values are in comma format. This occurs when I use ':' in input statement. When I do not use ':', SAS do not read the values of B and also the values of second record for A reads as tofucutlet 12,1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you sugest how to read the values correctly without changing any datalines?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2013 04:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Error/m-p/120075#M33064</guid>
      <dc:creator>Siddharth123</dc:creator>
      <dc:date>2013-08-23T04:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Error/m-p/120076#M33065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the problem is that SAS is confused because when no delimiter is specified for the infile statement, so the default is a space.&lt;/P&gt;&lt;P&gt;But on your input statement you've specified that for column A, it may contain a space by using the '&amp;amp;'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So how does SAS know if you mean a space in the value for column A or a space as a delimiter?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you specify a delimiter (except using a comma as you've also got a comma format being used for B) on the infile statement and also wrap column A's values with double quotes, this will get around this issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA test;&lt;BR /&gt; infile datalines dlm='*' dsd;&lt;BR /&gt; input A &amp;amp; $15. B :comma14.;&lt;BR /&gt;datalines;&lt;BR /&gt;"chocolate cream"*10,453&lt;BR /&gt;"tofucutlet"*12,187&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data = test;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use a comma as a delimiter too, only if you wrap the comma formated number in quotes too making sure you use the DSD option.&lt;/P&gt;&lt;P&gt;DATA test;&lt;BR /&gt; infile datalines dlm=',' dsd;&lt;BR /&gt; input A &amp;amp; $15. B :comma14.;&lt;BR /&gt;datalines;&lt;BR /&gt;"chocolate cream","10,453"&lt;BR /&gt;"tofucutlet","12,187"&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data = test;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know I've changed the datalines but I'm not sure if there is another way? Hope this helps as a starting point.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2013 07:04:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Error/m-p/120076#M33065</guid>
      <dc:creator>PaulLee</dc:creator>
      <dc:date>2013-08-23T07:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Error/m-p/120077#M33066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another alternative is to use add double spaces between variables and use the &amp;amp; symbol in the input statement to indicate where double spaces are used as delimiters. Here, I've added double spaces at the end of "chocolate cream" and "tofucutlet":&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input A &amp;amp; $14. B : comma14.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;chocolate cream&amp;nbsp; 10,453&lt;/P&gt;&lt;P&gt;tofucutlet&amp;nbsp; 12,187&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2013 08:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Error/m-p/120077#M33066</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2013-08-23T08:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SAS-Error/m-p/120078#M33067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="js-readmsg-link-box" id="style_13772471550000000000_BODY"&gt;data test;&lt;/P&gt;&lt;P&gt;length dlm $1;&lt;/P&gt;&lt;P&gt;dlm = ' ';&lt;/P&gt;&lt;P&gt;infile cards dsd dlm=dlm;&lt;/P&gt;&lt;P&gt;input @;&lt;/P&gt;&lt;P&gt;call scan(_infile_,1,start,_n_,dlm);&lt;/P&gt;&lt;P&gt;call scan(_infile_,-1,end,_n_,dlm);&lt;/P&gt;&lt;P&gt;length = end-start-1;&lt;/P&gt;&lt;P&gt;input a &lt;BR /&gt;$varying50. length +1 b : comma14.;&lt;/P&gt;&lt;P&gt;keep a b;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;chocolate cream 10,453&lt;/P&gt;&lt;P&gt;tofucutlet 12,187&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2013 08:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SAS-Error/m-p/120078#M33067</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2013-08-23T08:43:04Z</dc:date>
    </item>
  </channel>
</rss>

