<?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: Macro for calling CSV in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/273007#M310870</link>
    <description>&lt;P&gt;Thanks for catching that. I fixed the post.&lt;/P&gt;</description>
    <pubDate>Wed, 25 May 2016 13:12:17 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2016-05-25T13:12:17Z</dc:date>
    <item>
      <title>Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272988#M310860</link>
      <description>&lt;P&gt;I am having difficulties calling on the following macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro savecsv(dsin=, outfile=, outname=);&lt;/P&gt;
&lt;P&gt;libname csv odbc noprompt="DSN=csv;ReadOnly=0;DBQ=&amp;amp;outfile.;";&lt;/P&gt;
&lt;P&gt;proc datasets lib=csv nolist; &lt;BR /&gt;delete &amp;amp;outname.; &lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;data csv.&amp;amp;outname.; set &amp;amp;dsin; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;libname csv; &lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%savecsv(dsin=WORK.DAY2, &lt;BR /&gt;outfile=\\File\Reports\DAY2.csv, &lt;BR /&gt;outname=DAY2);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: CLI error trying to establish connection: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver &lt;BR /&gt; specified&lt;BR /&gt;ERROR: Error in the LIBNAME statement.&lt;BR /&gt;ERROR: Libref CSV is not assigned.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 12:41:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272988#M310860</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2016-05-25T12:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272991#M310861</link>
      <description>&lt;P&gt;I don't believe there's a libname for CSV.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If if you want to automate the input then use a proc import inside your macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 12:44:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272991#M310861</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-25T12:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272992#M310862</link>
      <description>&lt;P&gt;You have a problem with your ODBC driver as called in the libname csv odbc line. &amp;nbsp;Either the details you provide are not correct, the odbc isn't in the necessary location - be that on network, your machine or somewhere elese where SAS is being run, or it is not configured correctly. &amp;nbsp;You would need to lay the problem out to your IT group so they can fix it. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Although, why do you need to use ODBC to create a CSV in the first place? &amp;nbsp;Proc export can do it quite easily, or a data _null_ step and put the data items out, verfy simple Base SAS syntax, no need for macros and ODBC drivers etc.&lt;/P&gt;
&lt;PRE&gt;proc export data=sashelp.class outfile='c:\file.csv' dbms=csv replace;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 May 2016 12:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272992#M310862</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-25T12:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272994#M310863</link>
      <description>&lt;P&gt;At a guess, he is trying to ODBC to Excel. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 12:47:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272994#M310863</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-25T12:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272996#M310864</link>
      <description>&lt;P&gt;Allright but if I use the proc export function, it creates a lot of .bak files when this file is supposed to be replaced.&lt;/P&gt;
&lt;P&gt;I can't have that.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 12:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272996#M310864</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2016-05-25T12:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272998#M310865</link>
      <description>&lt;P&gt;Did you include the keyword replace?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also explicitly delete old files using fdelete first.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 12:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272998#M310865</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-25T12:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272999#M310866</link>
      <description>&lt;P&gt;What OS are you using? &amp;nbsp;I assume it is not Windows, as running a proc export will fail if file exists and you don't specify the replace command, so its likely your OS creating those files.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 12:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/272999#M310866</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-25T12:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/273000#M310867</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was doing it with an export to excel first but that failed with the .bak files. exporting with csv did not produces the .bak files...&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 12:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/273000#M310867</guid>
      <dc:creator>Kiteulf</dc:creator>
      <dc:date>2016-05-25T12:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/273002#M310868</link>
      <description>&lt;P&gt;There is no need to use ODBC or PROC EXPORT to create a CSV file. It is just a delimited file and SAS already knows how to write delimited files. &amp;nbsp;Only "trick" is getting the header line.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro savecsv(dsin=, outfile=);
proc transpose data=&amp;amp;dsin(obs=0);
 var _all_;
run;
data _null_;
   set &amp;amp;syslast end=eof;
   file "&amp;amp;outfile" dsd ;
   put _name_ @;
   if eof then put;
run;
data _null_;
   set &amp;amp;dsin;
   file "&amp;amp;outfile" dsd mod ;
   put (_all_) (+0) ;
run;
%mend savecsv ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 May 2016 13:11:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/273002#M310868</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-05-25T13:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/273005#M310869</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom﻿&lt;/a&gt; nice code - just for other readers the &lt;STRONG&gt;end=eof&lt;/STRONG&gt; shall be on &lt;STRONG&gt;set &lt;/STRONG&gt;statement.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 13:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/273005#M310869</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-05-25T13:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for calling CSV</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/273007#M310870</link>
      <description>&lt;P&gt;Thanks for catching that. I fixed the post.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 13:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-calling-CSV/m-p/273007#M310870</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-05-25T13:12:17Z</dc:date>
    </item>
  </channel>
</rss>

