<?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: Network File Names &amp; Formats in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39128#M10064</link>
    <description>Thank you all for your feedback, I appreciate your time and responses!&lt;BR /&gt;
&lt;BR /&gt;
I’ve read through the suggested links but I struggled with it since I’m beginner. &lt;BR /&gt;
&lt;BR /&gt;
I also ran the code that KSharp posted and it sort of gave me the results that I wanted but I failed to mention that I need the code to loop through each record in the file to confirm that each record is formatted as I mentioned above. &lt;BR /&gt;
&lt;BR /&gt;
However, rather than going down that road it may be easier if I elaborate a little more. &lt;BR /&gt;
&lt;BR /&gt;
Today, the below code runs which creates the adhoc_imports dataset.&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to modify this script to also create a dataset that has the file name that was being imported and within that dataset have a value that sets to Y or N depending upon if the file was imported? I really just need an audit trail identifying which files were written to adhoc_imports and those that were not. &lt;BR /&gt;
&lt;BR /&gt;
Thank you&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data WORK.adhoc_imports     ;                                                                                                               &lt;BR /&gt;
    %let _EFIERR_ = 0;                                                                         &lt;BR /&gt;
    infile "C:\adhoc*.txt" delimiter = "," MISSOVER DSD LRECL=350 firstobs=2 ;&lt;BR /&gt;
       informat Account $20. ;                                                                                                             &lt;BR /&gt;
       informat FieldCode $6. ;                                                                                                            &lt;BR /&gt;
       informat FieldValue $40. ;                                                                                                                  &lt;BR /&gt;
       informat CurRec $4. ;                                                                                                          &lt;BR /&gt;
       informat Current $5. ;                                                                                                             &lt;BR /&gt;
            format Account $20. ;                                                                                                               &lt;BR /&gt;
            format FieldCode $6. ;                                                                                                              &lt;BR /&gt;
            format FieldValue $40. ;                                                                                                                    &lt;BR /&gt;
            format CurRec $4. ;                                                                                                            &lt;BR /&gt;
            format Current $5. ;                                                                                                               &lt;BR /&gt;
              input                                                                                                                                    &lt;BR /&gt;
                   Account $                                                                                                                 &lt;BR /&gt;
                   FieldCode $                                                                                                                &lt;BR /&gt;
                   FieldValue $                                                                                                                      &lt;BR /&gt;
                   CurRec $                                                                                                              &lt;BR /&gt;
                   Current $  ;                                                                                                                                        &lt;BR /&gt;
    if _ERROR_ then call symputx('_EFIERR_',1);                                                    &lt;BR /&gt;
    run;</description>
    <pubDate>Thu, 31 Mar 2011 17:14:31 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2011-03-31T17:14:31Z</dc:date>
    <item>
      <title>Network File Names &amp; Formats</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39123#M10059</link>
      <description>Hello All – I’m a new SAS user and I’d like to know if there is a way to loop through a folder on a network share to identify the files within that folder that meet specific criterion. &lt;BR /&gt;
&lt;BR /&gt;
For example, the directory path is “S:\Del\ADHOC” and I want to identify the files in that folder which have a naming convention like adhoc*.txt. (* is a wildcard so as long as the file begins with adhoc and the type is .txt then the naming convention is good) &lt;BR /&gt;
&lt;BR /&gt;
Also, I need to identify that the files are comma delimited and that there are 5 columns formatted as such: Account $20. FieldCode $6. FieldValue $40. CurRec $4. Current $5.&lt;BR /&gt;
&lt;BR /&gt;
I want to create a dataset that contains the names of each file contained within the directory and set a value Y or N if it met the criterion. &lt;BR /&gt;
&lt;BR /&gt;
Is there a way to do this and if so can someone please assist with the code? &lt;BR /&gt;
&lt;BR /&gt;
Thank you&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Example Dataset: &lt;BR /&gt;
&lt;BR /&gt;
File_Nm	                           Success&lt;BR /&gt;
Adhoc_Test.txt         	             Y&lt;BR /&gt;
Adhoc_test1.txt                      N&lt;BR /&gt;
Adhoc_test3.xls                      N&lt;BR /&gt;
Adhoc_Test4.txt	             Y

Message was edited by: FlyTime88</description>
      <pubDate>Mon, 28 Mar 2011 13:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39123#M10059</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-28T13:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Network File Names &amp; Formats</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39124#M10060</link>
      <description>Yes, look at using FILENAME statement with PIPES, where you can supply a suitable command in quote marks for the OS to execute, such as an "ls" or "dir".&lt;BR /&gt;
&lt;BR /&gt;
This topic has been discussed in these forums and also you will find sample material / content at the SAS support &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website.  Also, the SAS support website has SAS-hosted product documentation and there will be a useful "companion" guide for your particular OS environment.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search argument, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
filename pipes os command read directory folder site:sas.com</description>
      <pubDate>Mon, 28 Mar 2011 16:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39124#M10060</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2011-03-28T16:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Network File Names &amp; Formats</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39125#M10061</link>
      <description>Hello.&lt;BR /&gt;
As Mr. Barry mentioned this question has been discussed many times.&lt;BR /&gt;
There is one of these discussions:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="&amp;lt;br"&gt;
&lt;/A&gt;&lt;A href="http://support.sas.com/forums/message.jspa?messageID=51742#51742" target="_blank"&gt;http://support.sas.com/forums/message.jspa?messageID=51742#51742&lt;/A&gt;&lt;BR /&gt;
&amp;gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/message.jspa?messageID=51742#51742" target="_blank"&gt;http://support.sas.com/forums/message.jspa?messageID=51742#51742&lt;/A&gt;&lt;BR /&gt;


Message was edited by: Oleg_L</description>
      <pubDate>Tue, 29 Mar 2011 05:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39125#M10061</guid>
      <dc:creator>Oleg_L</dc:creator>
      <dc:date>2011-03-29T05:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Network File Names &amp; Formats</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39126#M10062</link>
      <description>Give you an example.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let path=c:\temp\;&lt;BR /&gt;
filename fname pipe "dir &amp;amp;path.adhoc_*.txt /B";&lt;BR /&gt;
data result;&lt;BR /&gt;
 infile fname length=len;&lt;BR /&gt;
 input filename $varying200. len;&lt;BR /&gt;
 filename=cats("&amp;amp;path",filename);&lt;BR /&gt;
 &lt;BR /&gt;
 infile dummy filevar=filename length=len end=last;&lt;BR /&gt;
 _filename=scan(filename,-1,'\');&lt;BR /&gt;
 input row $varying200. len;&lt;BR /&gt;
&lt;BR /&gt;
 if length(scan(row,1,',')) eq 2 and    &lt;BR /&gt;
    length(scan(row,2,',')) eq 6 and &lt;BR /&gt;
    length(scan(row,3,',')) eq 4 and&lt;BR /&gt;
    length(scan(row,4,',')) eq 4 and&lt;BR /&gt;
    length(scan(row,5,',')) eq 5 &lt;BR /&gt;
  then success='Y';&lt;BR /&gt;
   else success='N'; &lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print noobs;run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
      _filename                  row               success&lt;BR /&gt;
&lt;BR /&gt;
   Adhoc_dsdq.txt     12 498983 duwr 49dw 98394       N&lt;BR /&gt;
   Adhoc_ffgfq.txt    12,498983,duwr,49dw,98394       Y&lt;BR /&gt;
   Adhoc_wq.txt       12,498983,duwr,49dw,98394       Y&lt;BR /&gt;
   Adhoc_wsaa.txt     12 498983 duwr 49dw 98394       N&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 29 Mar 2011 05:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39126#M10062</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-29T05:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Network File Names &amp; Formats</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39127#M10063</link>
      <description>FlyTime88&lt;BR /&gt;
 &lt;BR /&gt;
How far should validation of the criteria go?&lt;BR /&gt;
Reject if there are fewer columns?&lt;BR /&gt;
  Warn if extra columns are present?&lt;BR /&gt;
     Column headers implying data present but out of order?&lt;BR /&gt;
Column widths - too wide or narrow?&lt;BR /&gt;
Should 10/100/1000/all rows be tested?&lt;BR /&gt;
 &lt;BR /&gt;
peterC</description>
      <pubDate>Tue, 29 Mar 2011 06:23:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39127#M10063</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-03-29T06:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: Network File Names &amp; Formats</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39128#M10064</link>
      <description>Thank you all for your feedback, I appreciate your time and responses!&lt;BR /&gt;
&lt;BR /&gt;
I’ve read through the suggested links but I struggled with it since I’m beginner. &lt;BR /&gt;
&lt;BR /&gt;
I also ran the code that KSharp posted and it sort of gave me the results that I wanted but I failed to mention that I need the code to loop through each record in the file to confirm that each record is formatted as I mentioned above. &lt;BR /&gt;
&lt;BR /&gt;
However, rather than going down that road it may be easier if I elaborate a little more. &lt;BR /&gt;
&lt;BR /&gt;
Today, the below code runs which creates the adhoc_imports dataset.&lt;BR /&gt;
&lt;BR /&gt;
Is there a way to modify this script to also create a dataset that has the file name that was being imported and within that dataset have a value that sets to Y or N depending upon if the file was imported? I really just need an audit trail identifying which files were written to adhoc_imports and those that were not. &lt;BR /&gt;
&lt;BR /&gt;
Thank you&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data WORK.adhoc_imports     ;                                                                                                               &lt;BR /&gt;
    %let _EFIERR_ = 0;                                                                         &lt;BR /&gt;
    infile "C:\adhoc*.txt" delimiter = "," MISSOVER DSD LRECL=350 firstobs=2 ;&lt;BR /&gt;
       informat Account $20. ;                                                                                                             &lt;BR /&gt;
       informat FieldCode $6. ;                                                                                                            &lt;BR /&gt;
       informat FieldValue $40. ;                                                                                                                  &lt;BR /&gt;
       informat CurRec $4. ;                                                                                                          &lt;BR /&gt;
       informat Current $5. ;                                                                                                             &lt;BR /&gt;
            format Account $20. ;                                                                                                               &lt;BR /&gt;
            format FieldCode $6. ;                                                                                                              &lt;BR /&gt;
            format FieldValue $40. ;                                                                                                                    &lt;BR /&gt;
            format CurRec $4. ;                                                                                                            &lt;BR /&gt;
            format Current $5. ;                                                                                                               &lt;BR /&gt;
              input                                                                                                                                    &lt;BR /&gt;
                   Account $                                                                                                                 &lt;BR /&gt;
                   FieldCode $                                                                                                                &lt;BR /&gt;
                   FieldValue $                                                                                                                      &lt;BR /&gt;
                   CurRec $                                                                                                              &lt;BR /&gt;
                   Current $  ;                                                                                                                                        &lt;BR /&gt;
    if _ERROR_ then call symputx('_EFIERR_',1);                                                    &lt;BR /&gt;
    run;</description>
      <pubDate>Thu, 31 Mar 2011 17:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39128#M10064</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-31T17:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Network File Names &amp; Formats</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39129#M10065</link>
      <description>&amp;gt; Thank you all for your feedback, I appreciate your&lt;BR /&gt;
&amp;gt; time and responses!&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; However, rather than going down that road it may be&lt;BR /&gt;
&amp;gt; easier if I elaborate a little more. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Is there a way to modify this script to also create a&lt;BR /&gt;
&amp;gt; dataset that has the file name that was being&lt;BR /&gt;
&amp;gt; imported and within that dataset have a value that&lt;BR /&gt;
&amp;gt; sets to Y or N depending upon if the file was&lt;BR /&gt;
&amp;gt; imported? I really just need an audit trail&lt;BR /&gt;
&amp;gt; identifying which files were written to adhoc_imports&lt;BR /&gt;
&amp;gt; and those that were not. &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; Thank you&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; data WORK.adhoc_imports( compress=yes )     ;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
&amp;gt; %let _EFIERR_ = 0;&lt;BR /&gt;
&amp;gt; &lt;BR /&gt;
   length fn filename $1024 ; * two holders. One for infile option and one to "keep" ;&lt;BR /&gt;
   retain filename ;&lt;BR /&gt;
  infile "C:\adhoc*.txt" MISSOVER DSD LRECL=350 firstobs=2 filename=fn eov=eov ;&lt;BR /&gt;
 * establish column lengths / types ;&lt;BR /&gt;
length Account $20  FieldCode $6  FieldValue $40 CurRec $4 Current $5 ;&lt;BR /&gt;
   input @ ; * load a buffer to check for file change ;&lt;BR /&gt;
   if _n_ = 1 or eov then do ;&lt;BR /&gt;
      filename= fn ; * collect file name ;&lt;BR /&gt;
 **** and take any other action for the file name ;&lt;BR /&gt;
      eov = 0 ; * clear "file changed" flag at same time ;&lt;BR /&gt;
      error_count = 0 ;&lt;BR /&gt;
   end ;&lt;BR /&gt;
&lt;BR /&gt;
   input  Account -- Current   ;    * without trailing @ this releases the input buffer;&lt;BR /&gt;
   if _ERROR_ then ERRor_count +1 ; &lt;BR /&gt;
run ;</description>
      <pubDate>Thu, 31 Mar 2011 18:28:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39129#M10065</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-03-31T18:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Network File Names &amp; Formats</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39130#M10066</link>
      <description>Ksharp&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Ksharp

Message was edited by: Ksharp</description>
      <pubDate>Fri, 01 Apr 2011 10:06:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39130#M10066</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-01T10:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Network File Names &amp; Formats</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39131#M10067</link>
      <description>Opps.&lt;BR /&gt;
If you want all rows have the same length for each variable.Try the following, You need to &lt;BR /&gt;
change it a little,That is easy.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let path=c:\temp\;&lt;BR /&gt;
filename fname pipe "dir &amp;amp;path.adhoc_*.txt /B";&lt;BR /&gt;
data result;&lt;BR /&gt;
 infile fname length=len;&lt;BR /&gt;
 input filename $varying200. len;&lt;BR /&gt;
 filename=cats("&amp;amp;path",filename);&lt;BR /&gt;
 &lt;BR /&gt;
 infile dummy filevar=filename length=len end=last;&lt;BR /&gt;
 _filename=scan(filename,-1,'\');&lt;BR /&gt;
 do until(last);&lt;BR /&gt;
 input row $varying200. len;&lt;BR /&gt;
&lt;BR /&gt;
 if length(scan(row,1,',')) ne 2 or    &lt;BR /&gt;
    length(scan(row,2,',')) ne 6 or &lt;BR /&gt;
    length(scan(row,3,',')) ne 4 or&lt;BR /&gt;
    length(scan(row,4,',')) ne 4 or&lt;BR /&gt;
    length(scan(row,5,',')) ne 5 &lt;BR /&gt;
  then do;&lt;BR /&gt;
        success='N';&lt;BR /&gt;
        output;&lt;BR /&gt;
        leave;&lt;BR /&gt;
       end;&lt;BR /&gt;
&lt;BR /&gt;
 if last then do;&lt;BR /&gt;
                success='Y';&lt;BR /&gt;
                output;&lt;BR /&gt;
              end;&lt;BR /&gt;
 end;&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print noobs;run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
                          _filename                  row                success&lt;BR /&gt;
&lt;BR /&gt;
                       Adhoc_dsdq.txt     12 498983 duwr 49dw 98394        N&lt;BR /&gt;
                       Adhoc_ffgfq.txt    22,438983,dfsr,efrw,92354        Y&lt;BR /&gt;
                       Adhoc_wq.txt       222,438983,dfsr,efrw,92354       N&lt;BR /&gt;
                       Adhoc_wsaa.txt     12 498983 duwr 49dw 98394        N&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Sat, 02 Apr 2011 09:38:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Network-File-Names-Formats/m-p/39131#M10067</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-02T09:38:23Z</dc:date>
    </item>
  </channel>
</rss>

