<?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: Exporting a SAS dataset to the same folder and save it as text in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866407#M342140</link>
    <description>&lt;P&gt;And your question exactly is what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you did not provide an explicit path for the output text file it likely attempted to be placed in the directory SAS considers active. Depending on your SAS configuration that could mean it attempted to write to folder you don't have access to on a server or just someplace you did not look.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ALWAYS specify a complete path for output. Start with a drive letter or mount point and provide the complete path to the folder you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHAT did you log show? Did you look? Did you read the ERROR.&lt;/P&gt;
&lt;P&gt;Your first data step creates an error because you have a period as part of the file name:&lt;/P&gt;
&lt;PRE&gt;data outfile.thisfile_curday&lt;FONT size="6" color="#FF0000"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/PRE&gt;
&lt;P&gt;That is not legal syntax and no data set would be created.&lt;/P&gt;
&lt;P&gt;Then Proc Export would report the same illegal name&lt;/P&gt;
&lt;PRE&gt;139  proc export data=outfile.thisfile_curday.
ERROR: "OUTFILE.THISFILE_CURDAY." is not a valid name.
140      outfile="outfile.thisfile_curday..txt"
ERROR: Invalid data set name outfile.thisfile_curday.outfile.
140      outfile="outfile.thisfile_curday..txt"
                -
                22
ERROR 22-322: Syntax error, expecting one of the following: DATA, DBMS, FILE, OUTFILE, OUTTABLE,
              TABLE.

140      outfile="outfile.thisfile_curday..txt"
                -
                76
ERROR 76-322: Syntax error, statement will be ignored.

NO
&lt;/PRE&gt;
&lt;P&gt;So I would say that was a lot of "response".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF you correct the data set name problem to something valid the log will show you , besides data step code to accomplish the same thing, the location of the file if created. Using the SASHELP.CLASS data set as source for the export:&lt;/P&gt;
&lt;PRE&gt;144  proc export data=sashelp.class
145      outfile="outfile.thisfile_curday..txt"
146      dbms = dlm;
147      delimiter="|";
148  run;

149   /**********************************************************************
150   *   PRODUCT:   SAS
151   *   VERSION:   9.4
152   *   CREATOR:   External File Interface
153   *   DATE:      25MAR23
154   *   DESC:      Generated SAS Datastep Code
155   *   TEMPLATE SOURCE:  (None Specified.)
156   ***********************************************************************/
157      data _null_;
158      %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
159      %let _EFIREC_ = 0;     /* clear export record count macro variable */
160      file 'outfile.thisfile_curday..txt' delimiter='|' DSD DROPOVER lrecl=32767;
161      if _n_ = 1 then        /* write column names or labels */
162       do;
163         put
164            "Name"
165         '|'
166            "Sex"
167         '|'
168            "Age"
169         '|'
170            "Height"
171         '|'
172            "Weight"
173         ;
174       end;
175     set  SASHELP.CLASS   end=EFIEOD;
176         format Name $8. ;
177         format Sex $1. ;
178         format Age best12. ;
179         format Height best12. ;
180         format Weight best12. ;
181       do;
182         EFIOUT + 1;
183         put Name $ @;
184         put Sex $ @;
185         put Age @;
186         put Height @;
187         put Weight ;
188         ;
189       end;
190      if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
191      if EFIEOD then call symputx('_EFIREC_',EFIOUT);
192      run;

&lt;FONT size="5" color="#800080"&gt;NOTE: The file 'outfile.thisfile_curday..txt' is:
      Filename=C:\Users\Owner\outfile.thisfile_curday..txt,&lt;/FONT&gt;
      RECFM=V,LRECL=32767,File Size (bytes)=0,
      Last Modified=26Mar2023:13:31:02,
      Create Time=26Mar2023:13:31:02

&lt;/PRE&gt;
&lt;P&gt;The note after the execution shows where the output file was created on my system. Your path will start else where.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 26 Mar 2023 19:34:19 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-03-26T19:34:19Z</dc:date>
    <item>
      <title>Exporting a SAS dataset to the same folder and save it as text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866403#M342137</link>
      <description>&lt;PRE&gt;data outfile.thisfile_curday.;
set output.thisfile
run;
proc export data=outfile.thisfile_curday.
    outfile="outfile.thisfile_curday..txt"
    dbms = dlm;
    delimiter="|";
run;&lt;/PRE&gt;
&lt;P&gt;Respectfully,&lt;/P&gt;
&lt;P&gt;blue&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2023 18:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866403#M342137</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2023-03-26T18:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting a SAS dataset to the same folder and save it as text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866404#M342138</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This syntax doesn't create any response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;blue &amp;amp; blue&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2023 18:57:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866404#M342138</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2023-03-26T18:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting a SAS dataset to the same folder and save it as text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866407#M342140</link>
      <description>&lt;P&gt;And your question exactly is what?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you did not provide an explicit path for the output text file it likely attempted to be placed in the directory SAS considers active. Depending on your SAS configuration that could mean it attempted to write to folder you don't have access to on a server or just someplace you did not look.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ALWAYS specify a complete path for output. Start with a drive letter or mount point and provide the complete path to the folder you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHAT did you log show? Did you look? Did you read the ERROR.&lt;/P&gt;
&lt;P&gt;Your first data step creates an error because you have a period as part of the file name:&lt;/P&gt;
&lt;PRE&gt;data outfile.thisfile_curday&lt;FONT size="6" color="#FF0000"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/PRE&gt;
&lt;P&gt;That is not legal syntax and no data set would be created.&lt;/P&gt;
&lt;P&gt;Then Proc Export would report the same illegal name&lt;/P&gt;
&lt;PRE&gt;139  proc export data=outfile.thisfile_curday.
ERROR: "OUTFILE.THISFILE_CURDAY." is not a valid name.
140      outfile="outfile.thisfile_curday..txt"
ERROR: Invalid data set name outfile.thisfile_curday.outfile.
140      outfile="outfile.thisfile_curday..txt"
                -
                22
ERROR 22-322: Syntax error, expecting one of the following: DATA, DBMS, FILE, OUTFILE, OUTTABLE,
              TABLE.

140      outfile="outfile.thisfile_curday..txt"
                -
                76
ERROR 76-322: Syntax error, statement will be ignored.

NO
&lt;/PRE&gt;
&lt;P&gt;So I would say that was a lot of "response".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF you correct the data set name problem to something valid the log will show you , besides data step code to accomplish the same thing, the location of the file if created. Using the SASHELP.CLASS data set as source for the export:&lt;/P&gt;
&lt;PRE&gt;144  proc export data=sashelp.class
145      outfile="outfile.thisfile_curday..txt"
146      dbms = dlm;
147      delimiter="|";
148  run;

149   /**********************************************************************
150   *   PRODUCT:   SAS
151   *   VERSION:   9.4
152   *   CREATOR:   External File Interface
153   *   DATE:      25MAR23
154   *   DESC:      Generated SAS Datastep Code
155   *   TEMPLATE SOURCE:  (None Specified.)
156   ***********************************************************************/
157      data _null_;
158      %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
159      %let _EFIREC_ = 0;     /* clear export record count macro variable */
160      file 'outfile.thisfile_curday..txt' delimiter='|' DSD DROPOVER lrecl=32767;
161      if _n_ = 1 then        /* write column names or labels */
162       do;
163         put
164            "Name"
165         '|'
166            "Sex"
167         '|'
168            "Age"
169         '|'
170            "Height"
171         '|'
172            "Weight"
173         ;
174       end;
175     set  SASHELP.CLASS   end=EFIEOD;
176         format Name $8. ;
177         format Sex $1. ;
178         format Age best12. ;
179         format Height best12. ;
180         format Weight best12. ;
181       do;
182         EFIOUT + 1;
183         put Name $ @;
184         put Sex $ @;
185         put Age @;
186         put Height @;
187         put Weight ;
188         ;
189       end;
190      if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
191      if EFIEOD then call symputx('_EFIREC_',EFIOUT);
192      run;

&lt;FONT size="5" color="#800080"&gt;NOTE: The file 'outfile.thisfile_curday..txt' is:
      Filename=C:\Users\Owner\outfile.thisfile_curday..txt,&lt;/FONT&gt;
      RECFM=V,LRECL=32767,File Size (bytes)=0,
      Last Modified=26Mar2023:13:31:02,
      Create Time=26Mar2023:13:31:02

&lt;/PRE&gt;
&lt;P&gt;The note after the execution shows where the output file was created on my system. Your path will start else where.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2023 19:34:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866407#M342140</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-26T19:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting a SAS dataset to the same folder and save it as text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866409#M342142</link>
      <description>&lt;P&gt;There is an error on the line marked in green, can you see what the error is and fix it?&lt;/P&gt;
&lt;P&gt;There is an error on the line marked in red, can you see what the error is and fix it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#008000"&gt;&lt;STRONG&gt;data outfile.thisfile_curday.;&lt;/STRONG&gt;&lt;/FONT&gt;
&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;set output.thisfile&lt;/FONT&gt;&lt;/STRONG&gt;
run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Mar 2023 19:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866409#M342142</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-26T19:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting a SAS dataset to the same folder and save it as text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866411#M342144</link>
      <description>&lt;P&gt;Hello, thanks a lot for your response!&lt;BR /&gt;I added a semicolon to it.&amp;nbsp;&lt;BR /&gt;thanks for it!!!&lt;BR /&gt;blue blue&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2023 20:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866411#M342144</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2023-03-26T20:00:48Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting a SAS dataset to the same folder and save it as text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866413#M342146</link>
      <description>&lt;P&gt;Thanks for responses:&lt;/P&gt;
&lt;PRE&gt;data outfile.thisfile_curday&lt;FONT size="6" color="#FF0000"&gt;&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/PRE&gt;
&lt;P&gt;in reality it is &amp;amp;curday.; it is a macro variable&lt;/P&gt;
&lt;P&gt;I don’t know what the path is, it is on sas a remote location. It doesn’t start with a letter. That is why I pointed out to a direction introduced by a libname.&amp;nbsp;&lt;BR /&gt;thanks for your response.&lt;/P&gt;
&lt;P&gt;respectfully,&lt;/P&gt;
&lt;P&gt;blue&lt;/P&gt;</description>
      <pubDate>Sun, 26 Mar 2023 20:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866413#M342146</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2023-03-26T20:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting a SAS dataset to the same folder and save it as text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866421#M342154</link>
      <description>&lt;P&gt;The OUTFILE= option requires a physical path in the file system.&lt;/P&gt;
&lt;P&gt;A library reference&amp;nbsp;&lt;EM&gt;points&lt;/EM&gt; to a physical path, but you cannot use it as part of a physical path.&lt;/P&gt;
&lt;P&gt;Use your home directory on the server; if your server runs on UNIX (ask your SAS administrators), do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export
  data=outfile.thisfile_&amp;amp;curday.
  outfile="~/thisfile_&amp;amp;curday..txt"
  dbms=dlm
;
delimiter="|";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Mar 2023 21:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866421#M342154</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-26T21:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting a SAS dataset to the same folder and save it as text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866423#M342155</link>
      <description>&lt;P&gt;You could derive the physical path of the SAS library with the pathname() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data outfile.&amp;amp;thisfile_curday.;
  set output.thisfile;
run;

proc export data=outfile.&amp;amp;thisfile_curday.;
  outfile="%sysfunc(pathname(outfile))\&amp;amp;thisfile_curday..txt"
  dbms = dlm;
  delimiter="|";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 26 Mar 2023 22:04:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866423#M342155</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-03-26T22:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting a SAS dataset to the same folder and save it as text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866428#M342159</link>
      <description>let me try this and I will get back to you.&lt;BR /&gt;&lt;BR /&gt;Thank you so very much for your response.</description>
      <pubDate>Sun, 26 Mar 2023 23:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866428#M342159</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2023-03-26T23:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Exporting a SAS dataset to the same folder and save it as text</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866459#M342186</link>
      <description>&lt;P&gt;Mind that it is not recommended to clutter up SAS libraries with non-SAS files. It is also quite hard (and usually impossible) to find such files in the Files folder of Enterprise Guide.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2023 06:07:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Exporting-a-SAS-dataset-to-the-same-folder-and-save-it-as-text/m-p/866459#M342186</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-27T06:07:41Z</dc:date>
    </item>
  </channel>
</rss>

