<?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 cannot read a csv file that it has just created in the previous datastep. How to fix? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471536#M120797</link>
    <description>&lt;P&gt;Your example has single quotes, macro variables will only resolve in double quotes but without seeing the code it's anyone's guess.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216555"&gt;@bwilsonrelyea&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you Reeza. This does work. I do not have commas in a put statement in my real code - sorry. I still do not know why my code does not work. It could be because both parts are inside a macro, or that the file name and variable lists are macro variables - but that does not seem likely. I'll investigate some more. It's good to know that it actually works though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: 19 records were read from the infile '/////out.csv'.&lt;/P&gt;
&lt;P&gt;The minimum record length was 9.&lt;/P&gt;
&lt;P&gt;The maximum record length was 12.&lt;/P&gt;
&lt;P&gt;NOTE: The data set WORK.NEW has 19 observations and 3 variables.&lt;/P&gt;
&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;
&lt;P&gt;real time 0.00 seconds&lt;/P&gt;
&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Jun 2018 22:00:28 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-06-19T22:00:28Z</dc:date>
    <item>
      <title>SAS cannot read a csv file that it has just created in the previous datastep. How to fix?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471516#M120787</link>
      <description>&lt;P&gt;I am using SAS EG 7.15 on Linux using SAS 9.4. For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _NULL_;&lt;/P&gt;&lt;P&gt;set in;&lt;/P&gt;&lt;P&gt;file '////out.csv' delimiter=",";&lt;/P&gt;&lt;P&gt;if _n_=1 then put "var1, var2, etc";&lt;/P&gt;&lt;P&gt;put var1, var2, etc;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;infile '////out.csv' dlm="," dsd missover firstobs=2 termstr=CLRF;&lt;/P&gt;&lt;P&gt;input var1, var2, etc;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second data step cannot read the records created in the first data step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: 0 records were read from the infile '////out.csv' .&lt;BR /&gt;NOTE: The data set WORK.NEW has 0 observations and 6 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do we work around this?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 20:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471516#M120787</guid>
      <dc:creator>bwilsonrelyea</dc:creator>
      <dc:date>2018-06-19T20:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS cannot read a csv file that it has just created in the previous datastep. How to fix?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471518#M120788</link>
      <description>&lt;P&gt;Is the code you ran the code you posted?&lt;/P&gt;
&lt;P&gt;It's incorrect, the log should have errors? Or post the actual code or a reproducible example.&lt;/P&gt;
&lt;P&gt;The premise is correct and this type of logic can work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216555"&gt;@bwilsonrelyea&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am using SAS EG 7.15 on Linux using SAS 9.4. For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _NULL_;&lt;/P&gt;
&lt;P&gt;set in;&lt;/P&gt;
&lt;P&gt;file '////out.csv' delimiter=",";&lt;/P&gt;
&lt;P&gt;if _n_=1 then put "var1, var2, etc";&lt;/P&gt;
&lt;P&gt;put var1, var2, etc;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data new;&lt;/P&gt;
&lt;P&gt;infile '////out.csv' dlm="," dsd missover firstobs=2 termstr=CLRF;&lt;/P&gt;
&lt;P&gt;input var1, var2, etc;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second data step cannot read the records created in the first data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: 0 records were read from the infile '////out.csv' .&lt;BR /&gt;NOTE: The data set WORK.NEW has 0 observations and 6 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do we work around this?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 20:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471518#M120788</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-19T20:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS cannot read a csv file that it has just created in the previous datastep. How to fix?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471525#M120793</link>
      <description>&lt;P&gt;There were no error messages. This is just a simplified example. What do I have incorrect other than the etc?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used many was to create and read a csv file in one program run, including proc import/export and the %ds2cvs macro.&amp;nbsp;No method works. I have to physically go to the file and open the new csv and save it before executing the next&amp;nbsp;statement to read it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 21:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471525#M120793</guid>
      <dc:creator>bwilsonrelyea</dc:creator>
      <dc:date>2018-06-19T21:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: SAS cannot read a csv file that it has just created in the previous datastep. How to fix?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471529#M120795</link>
      <description>&lt;P&gt;Commas in the PUT statement for one. Picking a location you know you have access to, does this work for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;

set sashelp.class;

file 'C:\_localdata\temp\out.csv' delimiter=",";

if _n_=1 then put "name, age, sex";

put name age sex;

run;

 

data new;

infile 'C:\_localdata\temp\out.csv' dlm="," dsd missover firstobs=2;

input name $ age sex $;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Jun 2018 21:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471529#M120795</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-19T21:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS cannot read a csv file that it has just created in the previous datastep. How to fix?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471534#M120796</link>
      <description>&lt;P&gt;Thank you Reeza. This does work. I do not have commas in a put statement in my real code - sorry. I still do not know why my code does not work. It could be because both parts are inside a macro, or that the file name and variable lists are macro variables - but that does not seem likely. I'll investigate some more. It's good to know that it actually works though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: 19 records were read from the infile '/////out.csv'.&lt;/P&gt;&lt;P&gt;The minimum record length was 9.&lt;/P&gt;&lt;P&gt;The maximum record length was 12.&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.NEW has 19 observations and 3 variables.&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;real time 0.00 seconds&lt;/P&gt;&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 21:52:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471534#M120796</guid>
      <dc:creator>bwilsonrelyea</dc:creator>
      <dc:date>2018-06-19T21:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS cannot read a csv file that it has just created in the previous datastep. How to fix?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471536#M120797</link>
      <description>&lt;P&gt;Your example has single quotes, macro variables will only resolve in double quotes but without seeing the code it's anyone's guess.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216555"&gt;@bwilsonrelyea&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you Reeza. This does work. I do not have commas in a put statement in my real code - sorry. I still do not know why my code does not work. It could be because both parts are inside a macro, or that the file name and variable lists are macro variables - but that does not seem likely. I'll investigate some more. It's good to know that it actually works though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: 19 records were read from the infile '/////out.csv'.&lt;/P&gt;
&lt;P&gt;The minimum record length was 9.&lt;/P&gt;
&lt;P&gt;The maximum record length was 12.&lt;/P&gt;
&lt;P&gt;NOTE: The data set WORK.NEW has 19 observations and 3 variables.&lt;/P&gt;
&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;
&lt;P&gt;real time 0.00 seconds&lt;/P&gt;
&lt;P&gt;cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 22:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471536#M120797</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-19T22:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS cannot read a csv file that it has just created in the previous datastep. How to fix?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471561#M120800</link>
      <description>&lt;P&gt;I think I have it!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's the&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;termstr&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=CRLF.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;When I delete that it runs.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Thanks for all the help.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Barbara&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jun 2018 23:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-cannot-read-a-csv-file-that-it-has-just-created-in-the/m-p/471561#M120800</guid>
      <dc:creator>bwilsonrelyea</dc:creator>
      <dc:date>2018-06-19T23:36:21Z</dc:date>
    </item>
  </channel>
</rss>

