<?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: Using a Windows folder in a filename statement and trying to write many files within the folder in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874144#M345345</link>
    <description>&lt;P&gt;You do realize that the data step you posted&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Work.Gen_JCL;
filename CFG_SW 'z:\mainframe\GPSE\ITPro32gb\SW_CMDS';
%FICON_SW(CHB_PAIR='1A');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;makes NO sense what so ever.&lt;/P&gt;
&lt;P&gt;The macro you showed by for is generating a data step already.&amp;nbsp; So it is as if you want this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Work.Gen_JCL;
filename CFG_SW 'z:\mainframe\GPSE\ITPro32gb\SW_CMDS';
Data  Work.BLD_Switch_commands;
...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which is the equivalent of running&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Work.Gen_JCL;
run;
filename CFG_SW 'z:\mainframe\GPSE\ITPro32gb\SW_CMDS';
Data  Work.BLD_Switch_commands;
...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not sure why you want to create GEN_JCL dataset with one observation and zero variables.&lt;/P&gt;</description>
    <pubDate>Fri, 05 May 2023 14:32:25 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-05-05T14:32:25Z</dc:date>
    <item>
      <title>Using a Windows folder in a filename statement and trying to write many files within the folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874050#M345296</link>
      <description>&lt;P&gt;SAS V9.4 on Windows 10.&lt;/P&gt;
&lt;P&gt;I will be performing some testing of new storage behind a Brocade switch. The testing will require enabling and disabling specific ports and changing the speed for some ports.&lt;/P&gt;
&lt;P&gt;I have written a macro to build files for each test. They are being written to my user/me/ folder. I want to have the main program use a folder in the filename statement and then have each file I am building be a file within that Windows folder.&lt;/P&gt;
&lt;P&gt;I have a second issue. I have a series of nested loops. The outer most loop is&amp;nbsp; &amp;nbsp;'do type = 'A','N';&amp;nbsp; the inner most within each creates a file that has way too many lines in it. Most will have 8-10 records, the inner most within the TYPE loop however is getting hundreds. Perhaps&amp;nbsp; it is getting every record created and placed into the other files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So main question is: how do I set the file names to be in the folder&amp;nbsp; the main program uses as the location of the filename?&lt;/P&gt;
&lt;P&gt;2nd question is can you see why the inner most loop is getting an excessive number of records?&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 03:10:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874050#M345296</guid>
      <dc:creator>lchristensen</dc:creator>
      <dc:date>2023-05-05T03:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Windows folder in a filename statement and trying to write many files within the folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874083#M345314</link>
      <description>&lt;P&gt;Code like this is using a Fileref as the argument of the File statement. That means somewhere prior to this code executing There should be a Filename statement that creates the Fileref.&lt;/P&gt;
&lt;PRE&gt;if z_speed = '0' and Stg_speed = '0' 	then file AJG;&lt;/PRE&gt;
&lt;P&gt;The filename might look like&lt;/P&gt;
&lt;P&gt;Filename AJG "&amp;lt;folder&amp;gt;\something.txt";&lt;/P&gt;
&lt;P&gt;If you have an existing Fileref as described perhaps something like:&lt;/P&gt;
&lt;PRE&gt;data _null_;
   length path fname $ 200;  /*&amp;lt;= long enough to hold maximum expected path/filename*/
   /* check if the "existing" fileref is actually defined*/
   /* obviously the CFG_SW example could be a parameter to the
      macro change the base folder
   */
   rc=fileref("CFG_SW");
   if (rc=0) then
   /* found fileref so create filename statements*/
   do;
      /*get the path to the fileref */
      path=pathname("CFG_SW",F);
      do filext = 'AJL','AJR','AJX';/* list all of the file arguments */
         /* build the desired file name to use */
         fname = cats(path,'\',filext,'.txt');
         /* I would test this code with PUT statments before 
            actually executing the Filename 
         */
         put fname=;
         /* assign the fileref */
         rc= filename(filext,fname )  ;
         /* if the filename doesn't assign properly get message*/
         if rc ne 0 then do;
           txt= sysmsg();
          put fname=  ' Message: ' txt;
 
         end;
      end;
   end;
run;
&lt;/PRE&gt;
&lt;P&gt;Personally I would have this execute before the main macro to debug any issues with specific lists.&lt;/P&gt;
&lt;P&gt;If you don't want to manually list a bunch of the filerefs to use place them in a dataset and use that data set to get the values instead of the Filext loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your second issue means you may want to show what you are getting and examples of the "too many lines".&lt;/P&gt;
&lt;P&gt;Put should only write to the most recently assigned FILE destination. Since you don't show where any of the Filerefs are assigned for your code I can't tell what might be going on.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 08:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874083#M345314</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-05-05T08:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Windows folder in a filename statement and trying to write many files within the folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874105#M345320</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;You're looping through &lt;CODE class=" language-sas"&gt;do z_speed  =  '0','32','16','08'; &lt;/CODE&gt; but only define a file for&amp;nbsp;&lt;CODE class=" language-sas"&gt;z_speed = '0'&lt;/CODE&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;in which file should be written for the remaining values&amp;nbsp;&lt;CODE class=" language-sas"&gt;'32','16','08'&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;?&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do z_speed  =  '0','32','16','08';                 /* z15 speed (0=autonegotiate)         -2 */&lt;/CODE&gt;&lt;/PRE&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;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                     if z_speed = '0' and Stg_speed = '0'   then file AJG;
                     if z_speed = '0' and Stg_speed = '32'  then file AJM;
                     if z_speed = '0' and Stg_speed = '16'  then file AJS;
                     if z_speed = '0' and Stg_speed = '08'  then file AJY;

                     if z_speed = '0' and Stg_speed = '0'   then put @  001   "***  file AJG ***"  ;
                     if z_speed = '0' and Stg_speed = '32'  then put @  001   "***  file AJM ***"  ;
                     if z_speed = '0' and Stg_speed = '16'  then put @  001   "***  file AJS ***"  ;
                     if z_speed = '0' and Stg_speed = '08'  then put @  001   "***  file AJY ***"  ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 10:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874105#M345320</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2023-05-05T10:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Windows folder in a filename statement and trying to write many files within the folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874132#M345340</link>
      <description>&lt;P&gt;Data Work.Gen_JCL;&lt;BR /&gt;filename CFG_SW 'z:\mainframe\GPSE\ITPro32gb\SW_CMDS';&lt;BR /&gt;%FICON_SW(CHB_PAIR='1A');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data step invoking the macro has a filename statement. It stops at the folder SW_CMDS. What I would like is for the macro to then build each file within the folder (SW_CMDS) based on the test.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If running on z/OS I'm fairly certain that works when the filename points to a partitioned dataset with the macro doing a FILE (member-name) for the member.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 13:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874132#M345340</guid>
      <dc:creator>lchristensen</dc:creator>
      <dc:date>2023-05-05T13:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Windows folder in a filename statement and trying to write many files within the folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874134#M345341</link>
      <description>&lt;P&gt;I am not yet testing the other z_speeds and was thinking that since there's no matching if to assign a file then there'd be no output for those other speeds but I guess it used the last file statement. Easy enough to work around with something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if z_speed ne '0' then delete;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 13:55:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874134#M345341</guid>
      <dc:creator>lchristensen</dc:creator>
      <dc:date>2023-05-05T13:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Windows folder in a filename statement and trying to write many files within the folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874136#M345342</link>
      <description>&lt;P&gt;Correction:&lt;/P&gt;
&lt;P&gt;if z_speed NE '0' then leave;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Works as desired for that. Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 14:10:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874136#M345342</guid>
      <dc:creator>lchristensen</dc:creator>
      <dc:date>2023-05-05T14:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using a Windows folder in a filename statement and trying to write many files within the folder</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874144#M345345</link>
      <description>&lt;P&gt;You do realize that the data step you posted&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Work.Gen_JCL;
filename CFG_SW 'z:\mainframe\GPSE\ITPro32gb\SW_CMDS';
%FICON_SW(CHB_PAIR='1A');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;makes NO sense what so ever.&lt;/P&gt;
&lt;P&gt;The macro you showed by for is generating a data step already.&amp;nbsp; So it is as if you want this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Work.Gen_JCL;
filename CFG_SW 'z:\mainframe\GPSE\ITPro32gb\SW_CMDS';
Data  Work.BLD_Switch_commands;
...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which is the equivalent of running&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Work.Gen_JCL;
run;
filename CFG_SW 'z:\mainframe\GPSE\ITPro32gb\SW_CMDS';
Data  Work.BLD_Switch_commands;
...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not sure why you want to create GEN_JCL dataset with one observation and zero variables.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2023 14:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-a-Windows-folder-in-a-filename-statement-and-trying-to/m-p/874144#M345345</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-05T14:32:25Z</dc:date>
    </item>
  </channel>
</rss>

