<?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: Output .sh file using filename _fout statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Output-sh-file-using-filename-fout-statement/m-p/815344#M321827</link>
    <description>&lt;P&gt;Did you have working code before you attempted this macro approach? If so, show us that code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not show where the macro variable COUNT is assigned a value. So that is one likely problem point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not appear to actually use data set A anywhere. Then&amp;nbsp; your "Output" macro attempts to use a variable BBB that does not have a source to come from (no data set on a SET statement as shown) and your Work.A data set if created would only have one variable, Command, not BBB as attempted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any path used in a Filename statement should start at a drive (WINDOWS) or drive mount point, otherwise it is going to be treated as relative to the current operating directory and not pointing where you think it is.&lt;/P&gt;
&lt;P&gt;What did your log look like when submitting this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Set: OPTIONS MPRINT; then run the macro and show us the LOG of the result to see the code you are actually generating.&lt;/P&gt;</description>
    <pubDate>Fri, 27 May 2022 08:56:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-05-27T08:56:36Z</dc:date>
    <item>
      <title>Output .sh file using filename _fout statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-sh-file-using-filename-fout-statement/m-p/815342#M321825</link>
      <description>&lt;P&gt;Hi, I am trying to use filename _fout statement to output .sh file instead of proc export because I see that filename _fout can support permissions parameter. By Default, using proc export will not generate .sh file with executable permissions. Using filename _fout allows doing so.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let default_dir=/sas/config/Lev1/AppData;
%let filename=test.sh;
%macro test();
	data a;
	attrib command length=$1000.;
		%do j=1 %to &amp;amp;count;
			command="cp &amp;amp;default_dir./&amp;amp;&amp;amp;filename&amp;amp;j. &amp;amp;sas_app_root./csv/";
			output;
			command="unzip &amp;amp;sas_app_root./csv/&amp;amp;&amp;amp;filename&amp;amp;j. -d &amp;amp;sas_app_root./csv/";
			output;
			command="rm -f &amp;amp;sas_app_root./csv/&amp;amp;&amp;amp;filename&amp;amp;j.";
			output;
	
	
	    %end;
		run;
%mend;
%test;


%macro output();
filename _fout "&amp;amp;default_dir./csv/csv_poc.sh" permission='A::u::rwx,A::g::r-x,A::o::---'; 
	data _NULL_;
/* 	set WORK.shell_command; */
      file _fout;
		%do j=1 %to &amp;amp;count;
			put bbb;
			
	    %end;
  	 run;
   filename _fout;
   %mend;
%output;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I couldn't find a way to let filename function to take in value from work.a;&lt;/P&gt;&lt;P&gt;Also, it seems like it will not output bbb in the .sh file using my script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What did I do wrong?&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 07:13:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-sh-file-using-filename-fout-statement/m-p/815342#M321825</guid>
      <dc:creator>StickyRoll</dc:creator>
      <dc:date>2022-05-27T07:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Output .sh file using filename _fout statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Output-sh-file-using-filename-fout-statement/m-p/815344#M321827</link>
      <description>&lt;P&gt;Did you have working code before you attempted this macro approach? If so, show us that code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not show where the macro variable COUNT is assigned a value. So that is one likely problem point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not appear to actually use data set A anywhere. Then&amp;nbsp; your "Output" macro attempts to use a variable BBB that does not have a source to come from (no data set on a SET statement as shown) and your Work.A data set if created would only have one variable, Command, not BBB as attempted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any path used in a Filename statement should start at a drive (WINDOWS) or drive mount point, otherwise it is going to be treated as relative to the current operating directory and not pointing where you think it is.&lt;/P&gt;
&lt;P&gt;What did your log look like when submitting this code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Set: OPTIONS MPRINT; then run the macro and show us the LOG of the result to see the code you are actually generating.&lt;/P&gt;</description>
      <pubDate>Fri, 27 May 2022 08:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Output-sh-file-using-filename-fout-statement/m-p/815344#M321827</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-05-27T08:56:36Z</dc:date>
    </item>
  </channel>
</rss>

