<?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 subfolder/file size in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/subfolder-file-size/m-p/696167#M212596</link>
    <description>&lt;P&gt;All,&lt;/P&gt;
&lt;P&gt;Below code give list of files and their sizes but it will not give subfolder size/subfolder file sizes.&lt;/P&gt;
&lt;P&gt;is there a way that can read subfolder/file sizes .&lt;/P&gt;
&lt;P&gt;we disabled XCMD so need to use this SAS code.&lt;/P&gt;
&lt;P&gt;So I am looking for total folder size, subfolder size ,all file lists&amp;nbsp; and sizes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getfilesizes(directory, extension, dataset) ;
  data &amp;amp;dataset. ;
    length FILE $256 DTE 8 SIZE 8 DIRECTORY $256 FILRF FILRFB $8 ;
    format DTE datetime.;
    keep FILE DTE SIZE DIRECTORY ;
    DIRECTORY= "&amp;amp;directory";
    RC1      = filename(FILRF,DIRECTORY);
    DID      = dopen(FILRF);
    MEMCOUNT = dnum(DID);
    do I=1 to MEMCOUNT;
      FILE = dread(DID,I);
      if "&amp;amp;extension" = scan(FILE,-1,'.') or "&amp;amp;extension" = "all" then do;
        RC2 =filename(FILRFB, catx('/', DIRECTORY, FILE) );
        FID =fopen(FILRFB);
        if FID then do;
          DTE =input(finfo(FID,'Last Modified'),anydtdtm.);  
          SIZE=input(finfo(FID,'File Size (bytes)'),32.);
        end;
        else call missing(DTE,SIZE);
        output;
        RC3 =fclose(FID);
        RC4 =filename(FILRFB);
      end;
    end;
    RC5=dclose(DID); RC6=filename(FILRF);
  run;

  %mend getfilesizes;
libname test "/test";

%getfilesizes(directory=%sysfunc(pathname(test)), extension=all, dataset=folder_size)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;we can calculate file size by using picture format&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Proc-report-file-size-in-GBs/td-p/696146" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Proc-report-file-size-in-GBs/td-p/696146&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Nov 2020 12:27:35 GMT</pubDate>
    <dc:creator>sathya66</dc:creator>
    <dc:date>2020-11-03T12:27:35Z</dc:date>
    <item>
      <title>subfolder/file size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subfolder-file-size/m-p/696167#M212596</link>
      <description>&lt;P&gt;All,&lt;/P&gt;
&lt;P&gt;Below code give list of files and their sizes but it will not give subfolder size/subfolder file sizes.&lt;/P&gt;
&lt;P&gt;is there a way that can read subfolder/file sizes .&lt;/P&gt;
&lt;P&gt;we disabled XCMD so need to use this SAS code.&lt;/P&gt;
&lt;P&gt;So I am looking for total folder size, subfolder size ,all file lists&amp;nbsp; and sizes.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getfilesizes(directory, extension, dataset) ;
  data &amp;amp;dataset. ;
    length FILE $256 DTE 8 SIZE 8 DIRECTORY $256 FILRF FILRFB $8 ;
    format DTE datetime.;
    keep FILE DTE SIZE DIRECTORY ;
    DIRECTORY= "&amp;amp;directory";
    RC1      = filename(FILRF,DIRECTORY);
    DID      = dopen(FILRF);
    MEMCOUNT = dnum(DID);
    do I=1 to MEMCOUNT;
      FILE = dread(DID,I);
      if "&amp;amp;extension" = scan(FILE,-1,'.') or "&amp;amp;extension" = "all" then do;
        RC2 =filename(FILRFB, catx('/', DIRECTORY, FILE) );
        FID =fopen(FILRFB);
        if FID then do;
          DTE =input(finfo(FID,'Last Modified'),anydtdtm.);  
          SIZE=input(finfo(FID,'File Size (bytes)'),32.);
        end;
        else call missing(DTE,SIZE);
        output;
        RC3 =fclose(FID);
        RC4 =filename(FILRFB);
      end;
    end;
    RC5=dclose(DID); RC6=filename(FILRF);
  run;

  %mend getfilesizes;
libname test "/test";

%getfilesizes(directory=%sysfunc(pathname(test)), extension=all, dataset=folder_size)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;we can calculate file size by using picture format&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/Proc-report-file-size-in-GBs/td-p/696146" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Proc-report-file-size-in-GBs/td-p/696146&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 12:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subfolder-file-size/m-p/696167#M212596</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2020-11-03T12:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: subfolder/file size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/subfolder-file-size/m-p/696182#M212604</link>
      <description>&lt;P&gt;Just had a similar question today:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/List-of-Files-in-Directory-and-Subdirectories-with-File/m-p/696137/highlight/true#M212572" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/List-of-Files-in-Directory-and-Subdirectories-with-File/m-p/696137/highlight/true#M212572&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 13:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/subfolder-file-size/m-p/696182#M212604</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-03T13:20:59Z</dc:date>
    </item>
  </channel>
</rss>

