<?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: Need help deleting a file based on it's size in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843444#M333461</link>
    <description>&lt;P&gt;FYI - I modified your posted code into a code block and formatted it for legibility in your previous post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you can simplify your last few steps, see below for the rough idea. You can test and post the log if you're having issues. Note that you should test each step individually, ie assigning file refs, copy, delete and saving these stats to a data set helps track that. Once it's working, then change the data step to a data _null_ step.&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;/*Pull list of files from folder and their last save date*/
DATA ALL_FILES_DATES (KEEP=fname modified size ext);
	LENGTH fref $8;

	IF filename(fref, "/home/fkhurshed/Demo1")=0 THEN
		DO;
			did=dopen(fref);

			IF did ne 0 THEN
				DO;
					dnum=dnum(did);

					DO i=1 TO dnum;
						fname=dread(did, i);
						fid=mopen(did, fname);

						IF fid ne 0 THEN
							DO;
								modified=finfo(fid, 'Last Modified');
								size=round(finfo(fid, 'File Size (bytes)')/1024);
								ext = scan(fname, -1, ".");
								OUTPUT;
								fid=dclose(fid);
							END;
					END;
					did=dclose(did);
				END;
			rc=filename(fref);
		END;
RUN;

PROC SQL NOPRINT;
	CREATE TABLE ALL_FILES_DATES_SIZE AS SELECT * FROM ALL_FILES_DATES WHERE  ext='txt';
QUIT;

Proc sort data=ALL_FILES_DATES_SIZE(keep=fname size);
	by fname;
run;

options msglevel=i;

data temp;
	set ALL_FILES_DATES_SIZE;
	length msg $ 384;
	i=filename('ii', "/home/fkhurshed/Demo1/" || strip(fname), "DISK", "RECFM=N");
	o=filename('oo', "/home/fkhurshed/Demo2/" || strip(fname), "DISK", "RECFM=N");
	rc_copy=fcopy('ii', 'oo');
	msg_copy=sysmsg();

	if rc_copy=0 then do;
	     put 'Copied _bcin to _bcout.';
		 rc_delete=fdelete('ii');
		 msg_delete = sysmsg();
	end;	
		
	else
		do;
			
			put rc_copy= msg_copy=;
		end;
	i=filename('ii');
	o=filename('oo');
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;EDIT: This is tested and works for txt files. You can add in the size filter to the PROC SQL query to have it work on the sizes of interest but i didn't happen to have any files big enough so just left it as txt files. That seems to have dropped off somewhere in your first set of programs and the latest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Update your paths to get this working for you accordingly and to your OS - your paths are not specified properly in your code most, FOLDER_1 should be the full file path for SAS.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Nov 2022 18:53:53 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-11-09T18:53:53Z</dc:date>
    <item>
      <title>Need help deleting a file based on it's size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843434#M333453</link>
      <description>&lt;P&gt;Hello. I am trying to delete a file based on it's size.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to write a code that will look inside a folder, grab all the .txt files from it and if a .txt file is bigger than 135KB for example, I want it to be moved to a different folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I currently have so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let path=x;&lt;BR /&gt;filename filrf "&amp;amp;path.";&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;did = dopen('filrf');&lt;BR /&gt;memcount = dnum(did);&lt;BR /&gt;do while (memcount&amp;gt;0);&lt;BR /&gt;fname = dread(did,memcount);&lt;BR /&gt;size = round(finfo(fid,'File Size (bytes)')/1024);&lt;BR /&gt;if scan(lowcase(fname),2,'.')='txt'&lt;BR /&gt;and size &amp;gt; 135 then do;&lt;BR /&gt;rcref = filename('fref',catx('\',"&amp;amp;path.",fname));&lt;BR /&gt;rcdel = fdelete('fref');&lt;BR /&gt;end;&lt;BR /&gt;memcount+-1;&lt;BR /&gt;end;&lt;BR /&gt;stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was able to move the file to another folder using code, but I am not able to delete from first folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe this is not the right way to do it, so any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 18:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843434#M333453</guid>
      <dc:creator>EyeNeedHelp</dc:creator>
      <dc:date>2022-11-09T18:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Need help deleting a file based on it's size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843435#M333454</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;...&amp;nbsp;&lt;SPAN&gt;but I am not able to delete from first folder.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What happens? Is there an error message in the log? If so, show us the &lt;FONT color="#FF0000"&gt;entire&lt;/FONT&gt; log for this DATA step. What do you see that indicates you are not able to delete it?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 18:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843435#M333454</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-09T18:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need help deleting a file based on it's size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843436#M333455</link>
      <description>&lt;P&gt;Looks hard to read and I am not sure how to put it in a better format. I am novice to SAS so I am trying to use code that was used for other things as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Pull list of files from folder and their last save date*/
DATA ALL_FILES_DATES (KEEP=fname modified size);
	LENGTH fref $8;

	IF filename(fref, "FOLDER_1")=0 THEN
		DO;
			did=dopen(fref);

			IF did ne 0 THEN
				DO;
					dnum=dnum(did);

					DO i=1 TO dnum;
						fname=dread(did, i);
						fid=mopen(did, fname);

						IF fid ne 0 THEN
							DO;
								modified=finfo(fid, 'Last Modified');
								size=round(finfo(fid, 'File Size (bytes)')/1024);
								OUTPUT;
								fid=dclose(fid);
							END;
					END;
					did=dclose(did);
				END;
			rc=filename(fref);
		END;
RUN;

PROC SQL NOPRINT;
	CREATE TABLE ALL_FILES_DATES_SIZE AS SELECT * FROM ALL_FILES_DATES WHERE 
		SIZE &amp;gt; 135;
QUIT;

Proc sort data=ALL_FILES_DATES_SIZE out=loop1 (keep=fname size);
	by fname;
run;

options msglevel=i;

data _null_;
	set loop1;
	length msg $ 384;
	i=filename('ii', 'FOLDER_1' || strip(fname), "DISK", "RECFM=N");
	o=filename('oo', '\\FOLDER_2' || strip(fname), "DISK", "RECFM=N");
	rc=fcopy('ii', 'oo');

	if rc=0 then
		put 'Copied _bcin to _bcout.';
	else
		do;
			msg=sysmsg();
			put rc=msg=;
		end;
	i=filename('ii');
	o=filename('oo');
run;

%let path=FOLDER_1;
filename filrf "&amp;amp;path.";

data _null_;
	did=dopen('filrf');
	memcount=dnum(did);

	do while (memcount&amp;gt;0);
		fname=dread(did, memcount);
		size=round(finfo(fid, 'File Size (bytes)')/1024);

		if scan(lowcase(fname), 2, '.')='txt' and size &amp;gt; 135 then
			do;
				rcref=filename('fref', catx('\', "&amp;amp;path.", fname));
				rcdel=fdelete('fref');
			end;
		memcount+-1;
	end;
	stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, this might not be the right way to do it, but ultimately I want to delete all files from a folder if the file size is over 135KB.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 18:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843436#M333455</guid>
      <dc:creator>EyeNeedHelp</dc:creator>
      <dc:date>2022-11-09T18:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help deleting a file based on it's size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843439#M333457</link>
      <description>&lt;P&gt;This is not the log. Copy the log as text and paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1663012019648.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75161i0E71B1489A6C9839/image-size/large?v=v2&amp;amp;px=999" role="button" title="PaigeMiller_0-1663012019648.png" alt="PaigeMiller_0-1663012019648.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you need to answer my questions ... is there an error in the log? What happens that makes you think the file was not deleted?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 18:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843439#M333457</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-09T18:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need help deleting a file based on it's size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843440#M333458</link>
      <description>&lt;P&gt;This just the code, not the&amp;nbsp;&lt;STRONG&gt;log&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;Please post the log.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 18:29:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843440#M333458</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-09T18:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need help deleting a file based on it's size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843442#M333459</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;       
85         %let path=FOLDER_1
85       ! ;
86         filename filrf "&amp;amp;path.";
87         data _null_;
88           did = dopen('filrf');
89           memcount = dnum(did);
90           do while (memcount&amp;gt;0);
91             fname = dread(did,memcount);
92         	size = round(finfo(fid,'File Size (bytes)')/1024);
93             if scan(lowcase(fname),2,'.')='txt'
94         	and size &amp;gt; 135 then do;
95                 rcref = filename('fref',catx('\',"&amp;amp;path.",fname));
96                 rcdel = fdelete('fref');
97             end;
98             memcount+-1;
99           end;
100          stop;
101        run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      92:15   
INFO: Character variables have defaulted to a length of 200 at the places given by: (Line):(Column). Truncation can result.
      91:5     fname
NOTE: Variable fid is uninitialized.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
4                                                          The SAS System                          18:30 Wednesday, November 9, 2022

NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
NOTE: Argument 1 to function FINFO(.,'File Size (b'[12 of 17 characters shown]) at line 92 column 15 is invalid.
did=1 memcount=0 fname=AEPOH_Demand_20221109_060717.txt size=. fid=. rcref=. rcdel=. _ERROR_=1 _N_=1
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      49 at 92:9    49 at 92:45   
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

102        
103        GOPTIONS NOACCESSIBLE;
104        %LET _CLIENTTASKLABEL=;
105        %LET _CLIENTPROJECTPATH=;
106        %LET _CLIENTPROJECTNAME=;
107        %LET _SASPROGRAMFILE=;
108        
109        ;*';*";*/;quit;run;
110        ODS _ALL_ CLOSE;
111        
112        
5                                                          The SAS System                          18:30 Wednesday, November 9, 2022

113        QUIT; RUN;
114        &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 18:36:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843442#M333459</guid>
      <dc:creator>EyeNeedHelp</dc:creator>
      <dc:date>2022-11-09T18:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need help deleting a file based on it's size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843444#M333461</link>
      <description>&lt;P&gt;FYI - I modified your posted code into a code block and formatted it for legibility in your previous post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you can simplify your last few steps, see below for the rough idea. You can test and post the log if you're having issues. Note that you should test each step individually, ie assigning file refs, copy, delete and saving these stats to a data set helps track that. Once it's working, then change the data step to a data _null_ step.&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;/*Pull list of files from folder and their last save date*/
DATA ALL_FILES_DATES (KEEP=fname modified size ext);
	LENGTH fref $8;

	IF filename(fref, "/home/fkhurshed/Demo1")=0 THEN
		DO;
			did=dopen(fref);

			IF did ne 0 THEN
				DO;
					dnum=dnum(did);

					DO i=1 TO dnum;
						fname=dread(did, i);
						fid=mopen(did, fname);

						IF fid ne 0 THEN
							DO;
								modified=finfo(fid, 'Last Modified');
								size=round(finfo(fid, 'File Size (bytes)')/1024);
								ext = scan(fname, -1, ".");
								OUTPUT;
								fid=dclose(fid);
							END;
					END;
					did=dclose(did);
				END;
			rc=filename(fref);
		END;
RUN;

PROC SQL NOPRINT;
	CREATE TABLE ALL_FILES_DATES_SIZE AS SELECT * FROM ALL_FILES_DATES WHERE  ext='txt';
QUIT;

Proc sort data=ALL_FILES_DATES_SIZE(keep=fname size);
	by fname;
run;

options msglevel=i;

data temp;
	set ALL_FILES_DATES_SIZE;
	length msg $ 384;
	i=filename('ii', "/home/fkhurshed/Demo1/" || strip(fname), "DISK", "RECFM=N");
	o=filename('oo', "/home/fkhurshed/Demo2/" || strip(fname), "DISK", "RECFM=N");
	rc_copy=fcopy('ii', 'oo');
	msg_copy=sysmsg();

	if rc_copy=0 then do;
	     put 'Copied _bcin to _bcout.';
		 rc_delete=fdelete('ii');
		 msg_delete = sysmsg();
	end;	
		
	else
		do;
			
			put rc_copy= msg_copy=;
		end;
	i=filename('ii');
	o=filename('oo');
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;EDIT: This is tested and works for txt files. You can add in the size filter to the PROC SQL query to have it work on the sizes of interest but i didn't happen to have any files big enough so just left it as txt files. That seems to have dropped off somewhere in your first set of programs and the latest.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Update your paths to get this working for you accordingly and to your OS - your paths are not specified properly in your code most, FOLDER_1 should be the full file path for SAS.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 18:53:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843444#M333461</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-09T18:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help deleting a file based on it's size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843447#M333462</link>
      <description>&lt;P&gt;Correct, I have the correct paths, just didn't put into this forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested the code and it looks like it moved all the txt files not just the one that is bigger than 135KB&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 19:03:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843447#M333462</guid>
      <dc:creator>EyeNeedHelp</dc:creator>
      <dc:date>2022-11-09T19:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help deleting a file based on it's size</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843449#M333463</link>
      <description>&lt;P&gt;It worked! Thank you very much everyone!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 19:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-deleting-a-file-based-on-it-s-size/m-p/843449#M333463</guid>
      <dc:creator>EyeNeedHelp</dc:creator>
      <dc:date>2022-11-09T19:07:40Z</dc:date>
    </item>
  </channel>
</rss>

