<?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 Close a file in data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Close-a-file-in-data-set/m-p/248829#M46766</link>
    <description>&lt;P&gt;Hi, I have the following code in which a file is open in write mode.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename write "&amp;amp;batchfiledir\&amp;amp;batchname.sas";                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                
data _null_;                                                                                                                                                                                                                                                    
file write;                                                                                                                                                                                                                                                     
set _BatchfileData_ end=eof;                                                                                                                                                                                                                                    
length incstmnt $ 1000;                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                
if _n_=1 and lengthn(trim("&amp;amp;desc"))&amp;gt;0                                                                                                                                                                                                                           
  then put '/* Batch description: ' "&amp;amp;desc" ' */' /;                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                
incstmnt=cats("&amp;amp;tmpprotpath\", files);                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                
info=symget("mapunixdir_info");                                                                                                                                                                                                                                 
getunixdir=strip(scan(info,1,":"));                                                                                                                                                                                                                             
getwindir=strip(scan(info,2,":"));                                                                                                                                                                                                                              
incstmnt=tranwrd(incstmnt ,trim(getwindir),trim(getunixdir));                                                                                                                                                                                                   
incstmnt=translate(incstmnt,'/','\');                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                
  incstmnt=catt('%include "', incstmnt , '";' );                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                
  put incstmnt ;                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                
run;                                                                                                                                                                                                                                                            &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am getting&amp;nbsp;I/O error since this file is open in write mode and is not closed. Please suggest on ways to close this file.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Feb 2016 09:33:12 GMT</pubDate>
    <dc:creator>Arjumand</dc:creator>
    <dc:date>2016-02-09T09:33:12Z</dc:date>
    <item>
      <title>Close a file in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Close-a-file-in-data-set/m-p/248829#M46766</link>
      <description>&lt;P&gt;Hi, I have the following code in which a file is open in write mode.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename write "&amp;amp;batchfiledir\&amp;amp;batchname.sas";                                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                
data _null_;                                                                                                                                                                                                                                                    
file write;                                                                                                                                                                                                                                                     
set _BatchfileData_ end=eof;                                                                                                                                                                                                                                    
length incstmnt $ 1000;                                                                                                                                                                                                                                         
                                                                                                                                                                                                                                                                
if _n_=1 and lengthn(trim("&amp;amp;desc"))&amp;gt;0                                                                                                                                                                                                                           
  then put '/* Batch description: ' "&amp;amp;desc" ' */' /;                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                
incstmnt=cats("&amp;amp;tmpprotpath\", files);                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                
info=symget("mapunixdir_info");                                                                                                                                                                                                                                 
getunixdir=strip(scan(info,1,":"));                                                                                                                                                                                                                             
getwindir=strip(scan(info,2,":"));                                                                                                                                                                                                                              
incstmnt=tranwrd(incstmnt ,trim(getwindir),trim(getunixdir));                                                                                                                                                                                                   
incstmnt=translate(incstmnt,'/','\');                                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                
  incstmnt=catt('%include "', incstmnt , '";' );                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                
  put incstmnt ;                                                                                                                                                                                                                                                
                                                                                                                                                                                                                                                                
run;                                                                                                                                                                                                                                                            &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am getting&amp;nbsp;I/O error since this file is open in write mode and is not closed. Please suggest on ways to close this file.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 09:33:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Close-a-file-in-data-set/m-p/248829#M46766</guid>
      <dc:creator>Arjumand</dc:creator>
      <dc:date>2016-02-09T09:33:12Z</dc:date>
    </item>
    <item>
      <title>Betreff: Close a file in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Close-a-file-in-data-set/m-p/248844#M46769</link>
      <description>&lt;P&gt;Adding&lt;/P&gt;
&lt;PRE&gt;filename write clear;&lt;/PRE&gt;
&lt;P&gt;after run-statement should solve the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to add another period in your first filename-statement to create a properly named file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename write "&amp;amp;batchfiledir\&amp;amp;batchname..sas";  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first period is the separator between macro variable an following text and automatically ommitted.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 13:02:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Close-a-file-in-data-set/m-p/248844#M46769</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2016-02-09T13:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Close a file in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Close-a-file-in-data-set/m-p/248870#M46771</link>
      <description>&lt;P&gt;When you receive an error it is very helpfule to post the log and the entire text of the error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By any chance do you have any calls to the FOPEN function in your program elsewhere from the code you posted?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 15:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Close-a-file-in-data-set/m-p/248870#M46771</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-09T15:18:04Z</dc:date>
    </item>
  </channel>
</rss>

