<?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: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;amp;m*6)),best32.); in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499327#M132849</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&lt;/P&gt;&lt;P&gt;i&amp;nbsp; Tried running the script and it gave me the list of data that has blank _N_=2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when i run it to scan through 30k of excel csv, the programme will roughly takes 2 days based on the time needed for just 1k files that took about 2 hours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This script clearly slows down the entire process.....do you have any idea on how to improve it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have no choice but to skip tcnt when it doesnt exist because i will never know if any of the 30k csv has blank record or not. The file is not generated by me.&lt;/P&gt;</description>
    <pubDate>Thu, 27 Sep 2018 00:03:08 GMT</pubDate>
    <dc:creator>imdickson</dc:creator>
    <dc:date>2018-09-27T00:03:08Z</dc:date>
    <item>
      <title>Macro collides after a numbers of loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498923#M132674</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First of all, let me explain the situation now. I have a script that has macro to read from csv files, and then process with some calculation for every cells. The script is written to read all subfolders recursively.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The problem is, when I run the script to scan &lt;STRONG&gt;all subfolders&lt;/STRONG&gt;, it will generate errors after looping multiple times. When i say looping multiple times, i mean it could be more than a thousand times because i have 30k csv files in the main folder which&amp;nbsp;resides in&amp;nbsp;multiple subfolders. Here is the thing, the log shows :&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;WARNING: Apparent symbolic reference TCNT not resolved.&lt;BR /&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;tcnt&lt;BR /&gt;ERROR: The %TO value of the %DO M loop is invalid.&lt;BR /&gt;ERROR: The macro LIST_FILES will stop executing.&lt;BR /&gt;/sasdata/source/tttt/Profile_List_Files/Central/MDAM/Central_MDAM_33_201506.csv&lt;BR /&gt;Central_MDAM_33_201506&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As we can see, it starts to throw error when this file is being processed. What i did was to change the script to only read and process this particular file, &lt;SPAN&gt;Central_MDAM_33_201506.csv, instead of scanning the entire directory&lt;/SPAN&gt;. No issue at all. No warning no error and no (NOTE: Invalid XXX) at all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then tried to make it scan just 1k files including &lt;SPAN&gt;Central_MDAM_33_201506.csv&lt;/SPAN&gt;.&amp;nbsp;&lt;SPAN&gt;No issue at all. No warning no error and no (NOTE: Invalid XXX) at all.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;HOWEVER, when i run the script to scan through the main folder that consists of 30k files including&amp;nbsp;Central_MDAM_33_201506.csv, it starts throwing error again at this file and remain the same for the remaining files in the folder(shows in the log).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;After further research online, i believe this is the case of "Macro collide" where i have to add&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;%local &amp;lt;variable variable&amp;gt; (such as i j k cnt that i used in the loop within macro)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;and add code below after %mend&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;%sysmstoreclear;&lt;BR /&gt;%symdel &amp;lt;variable variable&amp;gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However, the same error appear even after the approach mentioned. Now I am cracking my head with my team and still unable to figure out which part is wrong.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;Do let me know if you want to see the script but the script is very long and previously there were experts like Tom and etc advised me not to use the proc import....... But feel free to ask me if you need the script, i will then post it.&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;I have attached the small part of the code that is within the macro in the post below.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But to wrap up, there wont be any error warning or invalid note if i were to just import 1 to 1000 csv files but ERROR(as above) when i let it scan 30k files.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 02:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498923#M132674</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-26T02:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498928#M132678</link>
      <description>&lt;P&gt;I have decided to post a small portion of the codes that is within the macro and containts tcnt which is in the log files.&lt;/P&gt;&lt;PRE&gt;data _null_; &lt;BR /&gt; set WORK.out (obs=2); &lt;BR /&gt; if _n_ = 2 then do; &lt;BR /&gt; tcnt = 0; &lt;BR /&gt; %do j=1 %to &amp;amp;cnt; &lt;BR /&gt; if &amp;amp;&amp;amp;col&amp;amp;j not in ("","Total") then do;&lt;BR /&gt; trxm = &amp;amp;&amp;amp;col&amp;amp;j;&lt;BR /&gt; call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt; call symputx("tcnt",tcnt);&lt;BR /&gt; tcnt+1;&lt;BR /&gt; end;&lt;BR /&gt; %end; &lt;BR /&gt; end; &lt;BR /&gt; run; &lt;BR /&gt;&lt;BR /&gt;data test (drop=			
		%do k=1 %to &amp;amp;cnt;			
		&amp;amp;&amp;amp;col&amp;amp;k..			
		%end;			
		);			
					
		length station $10 voltage $10 year 8 month $20 transformer $10			
		Day $20 Date Time MW_Imp MW_Exp MVAR_Imp MVAR_Exp MVA Power_Factor 8;			
		format Time hhmm.;			
		set 			
		out  end=last;			

		retain station voltage year month;			
		if _n_ = 1 then do;			
		station = VAR1;			
		voltage = VAR2;			
		year = input(VAR5,4.);			
		month = VAR3;			
		end;			
		if last then do;			
		month = strip(put(intnx('month',input(catt(substr(month,1,3),'1960'),monyy.),1),monname10.));			
		if month = "January" then year = year+1;			
		end;			
		 			
		if _n_ &amp;gt; 4 then do;			
		Day = VAR1;			
		Date = VAR2;			
		Time = input(VAR3,time.);			
		%do m=0 %to &amp;amp;tcnt;			
		transformer = "&amp;amp;&amp;amp;trxm&amp;amp;m..";			
		MW_Imp = input(VAR%eval(4+%eval(&amp;amp;m*6)),best32.);			
		MW_Exp = input(VAR%eval(5+%eval(&amp;amp;m*6)),best32.);			
		MVAR_Imp = input(VAR%eval(6+%eval(&amp;amp;m*6)),best32.);			
		MVAR_Exp = input(VAR%eval(7+%eval(&amp;amp;m*6)),best32.);			
		MVA = input(VAR%eval(8+%eval(&amp;amp;m*6)),best32.);			
		if MVA &amp;lt; 0.001 then Power_Factor = 0;			
		else Power_Factor = max(MW_Imp,MW_Exp)/MVA;			
					
		output;			
		%end;			
		end;			
		run;			&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly refer to code above.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I've said, no issue if i jsut scan for 1000 files....but when i let it scan for all files, error occur.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 02:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498928#M132678</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-26T02:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498931#M132680</link>
      <description>&lt;P&gt;1. It is impossible to know why the macro variable&amp;nbsp;&lt;SPAN&gt;TCNT&amp;nbsp;&lt;/SPAN&gt;is not created without seeing the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. You should always ensure the scope of your macro variables is perfectly explicit, i.e. use %local as much as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. This error message does not seem to be linked to an excess of recursions (the macro calling ifself).&lt;/P&gt;
&lt;P&gt;SAS can handle quite a few recursive calls depending on the task performed. This takes 5 seconds to run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let a=1;
%macro t; 
  %let a=%eval(&amp;amp;a+1); 
  %put &amp;amp;=a; 
  %if &amp;amp;a&amp;lt;1000 %then %t;
%mend; 
%t&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4.&amp;nbsp;If your code is long, I suggest you take out as much as you can (start by just running the loops with no inner processing) and slowly remove more and more code until the error goes away. You'll then know what causes it. Options MLOGIC and SYMBOLGEN can help see what the issue is.&lt;/P&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;</description>
      <pubDate>Wed, 26 Sep 2018 02:59:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498931#M132680</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-26T02:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498933#M132681</link>
      <description>&lt;P&gt;Following your update:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- From the code you posted, I see no reason why TNCT would suddenly no longer exist.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Try to pinpoint what line of code triggered the error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-&amp;nbsp;&lt;FONT face="courier new,courier"&gt;MW_Imp = input(VAR%eval(4+%eval(&amp;amp;m*6)),best32.);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; can be written as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;MW_Imp = input(VAR%eval(4+&amp;amp;m*6),best32.);&lt;/FONT&gt;&lt;/P&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;</description>
      <pubDate>Wed, 26 Sep 2018 03:07:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498933#M132681</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-26T03:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498935#M132682</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;This is the problem. I see no reason why tcnt would lost count suddenly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did put mprint mlogic previously but not sure if the log file is still being kept or removed. Let me try to search through the PC for it. I will post it later if i found it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 03:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498935#M132682</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-26T03:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498936#M132683</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below is the log when i enable mprint mlogic symbolgen&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;MPRINT(LIST_FILES): data _null_;&lt;BR /&gt;MPRINT(LIST_FILES): set WORK.out (obs=2);&lt;BR /&gt;MPRINT(LIST_FILES): if _n_ = 2 then do;&lt;BR /&gt;MPRINT(LIST_FILES): tcnt = 0;&lt;BR /&gt;MPRINT(LIST_FILES): if VAR1 not in ("","Total") then do;&lt;BR /&gt;MPRINT(LIST_FILES): trxm = VAR1;&lt;BR /&gt;MPRINT(LIST_FILES): call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt;MPRINT(LIST_FILES): call symputx("tcnt",tcnt);&lt;BR /&gt;MPRINT(LIST_FILES): tcnt+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if VAR2 not in ("","Total") then do;&lt;BR /&gt;MPRINT(LIST_FILES): trxm = VAR2;&lt;BR /&gt;MPRINT(LIST_FILES): call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt;MPRINT(LIST_FILES): call symputx("tcnt",tcnt);&lt;BR /&gt;MPRINT(LIST_FILES): tcnt+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if VAR3 not in ("","Total") then do;&lt;BR /&gt;MPRINT(LIST_FILES): trxm = VAR3;&lt;BR /&gt;MPRINT(LIST_FILES): call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt;MPRINT(LIST_FILES): call symputx("tcnt",tcnt);&lt;BR /&gt;MPRINT(LIST_FILES): tcnt+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if VAR4 not in ("","Total") then do;&lt;BR /&gt;MPRINT(LIST_FILES): trxm = VAR4;&lt;BR /&gt;MPRINT(LIST_FILES): call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt;MPRINT(LIST_FILES): call symputx("tcnt",tcnt);&lt;BR /&gt;MPRINT(LIST_FILES): tcnt+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if VAR5 not in ("","Total") then do;&lt;BR /&gt;MPRINT(LIST_FILES): trxm = VAR5;&lt;BR /&gt;MPRINT(LIST_FILES): call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt;MPRINT(LIST_FILES): call symputx("tcnt",tcnt);&lt;BR /&gt;MPRINT(LIST_FILES): tcnt+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if VAR6 not in ("","Total") then do;&lt;BR /&gt;MPRINT(LIST_FILES): trxm = VAR6;&lt;BR /&gt;MPRINT(LIST_FILES): call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt;MPRINT(LIST_FILES): call symputx("tcnt",tcnt);&lt;BR /&gt;MPRINT(LIST_FILES): tcnt+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if VAR7 not in ("","Total") then do;&lt;BR /&gt;MPRINT(LIST_FILES): trxm = VAR7;&lt;BR /&gt;MPRINT(LIST_FILES): call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt;MPRINT(LIST_FILES): call symputx("tcnt",tcnt);&lt;BR /&gt;MPRINT(LIST_FILES): tcnt+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if VAR8 not in ("","Total") then do;&lt;BR /&gt;MPRINT(LIST_FILES): trxm = VAR8;&lt;BR /&gt;MPRINT(LIST_FILES): call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt;MPRINT(LIST_FILES): call symputx("tcnt",tcnt);&lt;BR /&gt;MPRINT(LIST_FILES): tcnt+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if VAR9 not in ("","Total") then do;&lt;BR /&gt;MPRINT(LIST_FILES): trxm = VAR9;&lt;BR /&gt;MPRINT(LIST_FILES): call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt;MPRINT(LIST_FILES): call symputx("tcnt",tcnt);&lt;BR /&gt;MPRINT(LIST_FILES): tcnt+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if VAR10 not in ("","Total") then do;&lt;BR /&gt;MPRINT(LIST_FILES): trxm = VAR10;&lt;BR /&gt;MPRINT(LIST_FILES): call symputx(compress("trxm"||tcnt),compress(trxm));&lt;BR /&gt;MPRINT(LIST_FILES): call symputx("tcnt",tcnt);&lt;BR /&gt;MPRINT(LIST_FILES): tcnt+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): run;&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;BR /&gt;366618:104 366618:104 366618:104 366618:104 366618:104 366618:104 366618:104 366618:104 366618:104 366618:104&lt;BR /&gt;NOTE: There were 2 observations read from the data set WORK.OUT.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MPRINT(LIST_FILES): data test (drop= VAR1 VAR2 VAR3 VAR4 VAR5 VAR6 VAR7 VAR8 VAR9 VAR10 );&lt;BR /&gt;MPRINT(LIST_FILES): length station $10 voltage $10 year 8 month $20 transformer $10 Day $20 Date Time MW_Imp MW_Exp MVAR_Imp MVAR_Exp MVA Power_Factor 8;&lt;BR /&gt;MPRINT(LIST_FILES): format Time hhmm.;&lt;BR /&gt;MPRINT(LIST_FILES): set out end=last;&lt;BR /&gt;MPRINT(LIST_FILES): retain station voltage year month;&lt;BR /&gt;MPRINT(LIST_FILES): if _n_ = 1 then do;&lt;BR /&gt;MPRINT(LIST_FILES): station = VAR1;&lt;BR /&gt;MPRINT(LIST_FILES): voltage = VAR2;&lt;BR /&gt;MPRINT(LIST_FILES): year = input(VAR5,4.);&lt;BR /&gt;MPRINT(LIST_FILES): month = VAR3;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if last then do;&lt;BR /&gt;MPRINT(LIST_FILES): month = strip(put(intnx('month',input(catt(substr(month,1,3),'1960'),monyy.),1),monname10.));&lt;BR /&gt;MPRINT(LIST_FILES): if month = "January" then year = year+1;&lt;BR /&gt;MPRINT(LIST_FILES): end;&lt;BR /&gt;MPRINT(LIST_FILES): if _n_ &amp;gt; 4 then do;&lt;BR /&gt;MPRINT(LIST_FILES): Day = VAR1;&lt;BR /&gt;MPRINT(LIST_FILES): Date = VAR2;&lt;BR /&gt;MPRINT(LIST_FILES): Time = input(VAR3,time.);&lt;BR /&gt;WARNING: Apparent symbolic reference TCNT not resolved.&lt;BR /&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: &amp;amp;tcnt&lt;BR /&gt;ERROR: The %TO value of the %DO M loop is invalid.&lt;BR /&gt;ERROR: The macro LIST_FILES will stop executing.&lt;BR /&gt;/sasdata/source/tttt/Profile_List_Files/Central/MDAM/Central_MDAM_33_201506.xls&lt;BR /&gt;Central_MDAM_33_201506&lt;/P&gt;&lt;P&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).&lt;BR /&gt;366618:119&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.TEST may be incomplete. When this step was stopped there were 0 observations and 14 variables.&lt;BR /&gt;WARNING: Data set WORK.TEST was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;BR /&gt;&lt;BR /&gt;NOTE: Line generated by the invoked macro "LIST_FILES".&lt;BR /&gt;366618 PROC IMPORT OUT=WORK.out DATAFILE= "&amp;amp;dir/&amp;amp;name" DBMS=csv REPLACE; delimiter='09'x; getnames=no; RUN; proc contents data=out noprint out=data_info ; run; data _null_; set&lt;BR /&gt;_&lt;BR /&gt;117&lt;/P&gt;&lt;P&gt;MPRINT(LIST_FILES): PROC IMPORT OUT=WORK.out DATAFILE= "/sasdata/source/tttt/Profile_List_Files/Central/MDAM/Central_MDAM_33_201506.xls" DBMS=csv REPLACE;&lt;BR /&gt;ERROR 117-185: There was 1 unclosed DO block.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 26 Sep 2018 03:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498936#M132683</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-26T03:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498940#M132686</link>
      <description>&lt;P&gt;Following the log snippet you included :&lt;/P&gt;
&lt;P&gt;1. Remove the data step error:&amp;nbsp;&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;ERROR 117-185: There was 1 unclosed DO block.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. The data step will never call symputx()&amp;nbsp; when TNCT=0. This could cause the issue you reported.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3. Strive to have a clean log and remove&amp;nbsp;&lt;FONT face="courier new,courier"&gt;NOTE: Numeric values have been converted to character values&amp;nbsp;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 03:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498940#M132686</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-26T03:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498941#M132687</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;you mean you want the above log by removing the 3 items from the log that you just listed out?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 03:52:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498941#M132687</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-26T03:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498942#M132688</link>
      <description>&lt;P&gt;I mean items 1 and 3 indicate an issue with the program&amp;nbsp;logic&amp;nbsp;and should be corrected.&lt;/P&gt;
&lt;P&gt;Item 2 is probably why you get the issue you asked about.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 03:59:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498942#M132688</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-26T03:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498957#M132699</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;the problem is, i dont see the problem in that datastep or source file or processing logic because if i run just 1 file or 1000 files which includes the file that were listed in the log, there wont be any error at all. What I am doing is slowly add up more and more files until i know how many files will cause the macro to throw error again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When running the script with reading less csv, there is no error or warning to tell any logic at all. The final step of this code will append all data into one table. I can see all data display properly in the final table. Hence the confusion and headache I am having right now.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 05:56:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498957#M132699</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-26T05:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498962#M132702</link>
      <description>&lt;P&gt;Potential issues:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. If no test is not true when reading WORK.OUT (&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;data _null_;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;set WORK.out (obs=2);&lt;/SPAN&gt;&lt;/FONT&gt;) , TCNT does not get a assigned.&lt;/P&gt;
&lt;P&gt;I am pretty sure that's the reason for the issue as I stated before. All VARx variables must be blank or something similar.&lt;/P&gt;
&lt;P&gt;Add&amp;nbsp; the statement&lt;FONT face="courier new,courier"&gt;&amp;nbsp; &amp;nbsp;putlog TCNT=;&amp;nbsp;&lt;/FONT&gt; just before&lt;FONT face="courier new,courier"&gt; run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Once this data issue has been verified, you need to change the macro to cater for such cases.&lt;/P&gt;
&lt;P&gt;You also need to add the missing &lt;FONT face="courier new,courier"&gt;%local&lt;/FONT&gt; statement and fix&amp;nbsp;the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;NOTE: Numeric values have been converted to character&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your log must be clean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3.This&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set WORK.out (obs=2);
  if _n_ = 2 then do;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;would be clearer as&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set WORK.out (firstobs=2 obs=2);  * no more _N_ test needed;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 06:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498962#M132702</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-26T06:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498975#M132711</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;I found out that the file before the one that is in log file is the actual cost due to the 2nd row of that file only has BLANK and Total. I was expecting every file to have T1 value in _N_ =2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So what i want to do is to detect if _N_ not in (T1) then skip. Is there a way to plot in to the original code below?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	data _null_;			
		set WORK.out (obs=2);			
			if _n_ = 2 then do;		
			tcnt = 0;		
				%do j=1 %to &amp;amp;cnt;	
					if &amp;amp;&amp;amp;col&amp;amp;j not in ("","Total") then do;
					trxm = &amp;amp;&amp;amp;col&amp;amp;j;
					call symputx(compress("trxm"||tcnt),compress(trxm));
					call symputx("tcnt",tcnt);
					tcnt+1;
					end;
				%end;	
			end;		
		run;	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;i think i want not just to skip this loop but all other remaining if condition within the loop as this csv without T1 is considered as blank file so no need to process anything at all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your help is very much appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 07:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/498975#M132711</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-26T07:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499002#M132728</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I plan to use&amp;nbsp;%symexist(tcnt) to find out if it exist or not. If exists, check if is&amp;nbsp;zero. If it meets this criteria, output &amp;amp;name into dataset blankpage else continue to execute the remaining of the codes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code that I've been thinking:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data checkcnt;
%if %symexist(tcnt) %then %do;
%put tcnt is available;
%end;
%else %do;
%put tcnt is missing;
blankfilename = "&amp;amp;name";&lt;BR /&gt;&lt;BR /&gt; output;
%end;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;in my log file, i managed to see tnct is missing. Now i am able to&amp;nbsp;print tnct is missing, output the value in &amp;amp;name to dataset checkcnt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, i want to make it to continue to process with the remaining of the code if symexist(tcnt) is true....otherwise SKIP this current iteration to the next loop and&amp;nbsp;&lt;SPAN&gt;output the value in &amp;amp;name to dataset checkcnt.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, my remaining code is in a data step......how should i edit it so that it can be integrated?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 10:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499002#M132728</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-26T10:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499028#M132733</link>
      <description>&lt;P&gt;Hi, I managed to got it working....thanks everyone for the help.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 11:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499028#M132733</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-26T11:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499279#M132830</link>
      <description>&lt;P&gt;You should not be using&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macrostatement"&gt;%if&lt;/SPAN&gt; &lt;SPAN class="token macroname"&gt;%symexist&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;tcnt&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%then&lt;/SPAN&gt; &lt;SPAN class="token macrostatement"&gt;%do&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as the macro should be &lt;FONT face="courier new,courier"&gt;%local&lt;/FONT&gt;, so always exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you not fix any of the other issues I mentioned either, and lay the bed for more headaches for the person coming after you?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 21:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499279#M132830</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-26T21:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499288#M132835</link>
      <description>&lt;P&gt;I suspect that a lot of the issues will go away if you convert more of your macro code into actual SAS code. For example what are the %DO loops doing in this step that you couldn't do with data step code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also in addition to the logic issue of no observations matching your IF/THEN/ELSE block you need to also watch out for data steps that use CALL SYMPUTX() in code that comes after a place where the data step could stop. That is after a SET or INPUT statement.&amp;nbsp; No value will be set to the macro variable when the input data set was no observations since the data step will halt when the SET statement reads past the end of the input data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/63520"&gt;@imdickson&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;I found out that the file before the one that is in log file is the actual cost due to the 2nd row of that file only has BLANK and Total. I was expecting every file to have T1 value in _N_ =2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what i want to do is to detect if _N_ not in (T1) then skip. Is there a way to plot in to the original code below?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	data _null_;			
		set WORK.out (obs=2);			
			if _n_ = 2 then do;		
			tcnt = 0;		
				%do j=1 %to &amp;amp;cnt;	
					if &amp;amp;&amp;amp;col&amp;amp;j not in ("","Total") then do;
					trxm = &amp;amp;&amp;amp;col&amp;amp;j;
					call symputx(compress("trxm"||tcnt),compress(trxm));
					call symputx("tcnt",tcnt);
					tcnt+1;
					end;
				%end;	
			end;		
		run;	&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;i think i want not just to skip this loop but all other remaining if condition within the loop as this csv without T1 is considered as blank file so no need to process anything at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your help is very much appreciated.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2018 21:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499288#M132835</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-26T21:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499327#M132849</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&lt;/P&gt;&lt;P&gt;i&amp;nbsp; Tried running the script and it gave me the list of data that has blank _N_=2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when i run it to scan through 30k of excel csv, the programme will roughly takes 2 days based on the time needed for just 1k files that took about 2 hours.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This script clearly slows down the entire process.....do you have any idea on how to improve it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have no choice but to skip tcnt when it doesnt exist because i will never know if any of the 30k csv has blank record or not. The file is not generated by me.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 00:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499327#M132849</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-27T00:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499329#M132851</link>
      <description>&lt;P&gt;What does the program do?&amp;nbsp; Why does it need to use macro code to do it?&amp;nbsp; What SAS code is the macro generating?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by "30K of excel csv"?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are there 30,000 different files?&amp;nbsp; Just reading the list of file names will take a long time.&amp;nbsp; Can you place them on a RAM disk and read from there?&amp;nbsp; Or are you talking about how big one of the files is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are they CSV files (which are simple text files) or Excel files (which is a binary format)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 00:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499329#M132851</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-09-27T00:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499331#M132852</link>
      <description>&lt;P&gt;1. Performance&lt;/P&gt;
&lt;P&gt;I have no idea what your program does.&lt;/P&gt;
&lt;P&gt;Two hours seems excessive for processing 1000 files, but as usual, it depends (on the files, the processing, the hardware).&lt;/P&gt;
&lt;P&gt;7 seconds per file seems ludicrous to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. You don't seem to take my advice into account much.&lt;/P&gt;
&lt;P&gt;If you don't strive to write clean programs, you just create problems for yourself, and you'll end up here asking questions more often than necessary.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 00:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499331#M132852</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-09-27T00:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro collides after a numbers of loops MW_Imp = input(VAR%eval(4+%eval(&amp;m*6)),best32.);</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499337#M132856</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;this is the script that i mentioned in another thread before but this time round is another issue.&lt;/P&gt;&lt;P&gt;This script will first read 30k of seperate csv files in multiple subfolders that will be scanned by recursive macro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once it is read, it will then do some checking on the rows of excel first. For example, If 1st row then assign 1st column to a Variable.&lt;/P&gt;&lt;P&gt;If 2nd row, scan for any value that is not BLANK or TOTAL. However, after running the previous script for a few rounds, i noticed there are errors caused by some CSV that are not having any other value apart from BLANK or TOTAL in 2nd row. This is actually the type of CSV that i should be avoiding to load. Since I've assigned counter for 2nd row and if it has nothing(Apart from BLANK or TOTAL), the counter will not be initialized. I then use symexists to check if the counter for 2nd row(tcnt) exist or not. If it exists, proceed with all other formula calculation for each column and etc. Otherwise, i want to output the filename that tcnt doesnt exists into a table for a full list of bad csv file and i've also included "CONTINUE" at the end of the else statement to skip the current iteration.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when i make the script to scan for jsut 3 files, it will output the bad csv into a table called blankfilelist. When i make the script to scan for 1000 files which contains 1 or 2 bad csv file, it will never hit the condition of symexists else(which indicates tcnt doesnt exist).&lt;/P&gt;&lt;PRE&gt;DATA FINALTESTONE;					
STOP;					
length station $10 voltage $10 year 8 month $20 transformer $10					
		Day $20 Date Time MW_Imp MW_Exp MVAR_Imp MVAR_Exp MVA Power_Factor 8;			
	RUN;

data blankfilelist;
stop;
length blankfilename $50.;
run;
	
options nomprint nomlogic nosymbolgen;



%macro list_files(dir,ext);					
	%local filrf rc did memcnt name i;				
	%let rc=%sysfunc(filename(filrf,&amp;amp;dir));				
	%let did=%sysfunc(dopen(&amp;amp;filrf));				
					
	%if &amp;amp;did eq 0 %then				
		%do;			
			%put Directory &amp;amp;dir cannot be open or does not exist;		
					
			%return;		
		%end;			
					
	%do i = 1 %to %sysfunc(dnum(&amp;amp;did));				
		%let name=%qsysfunc(dread(&amp;amp;did,&amp;amp;i));			
					
		%if %qupcase(%qscan(&amp;amp;name,-1,.)) = %upcase(&amp;amp;ext) %then			
			%do;		
				%put &amp;amp;dir/&amp;amp;name;	
				%let file_name =  %qscan(&amp;amp;name,1,.);	
				%put &amp;amp;file_name;	
				/*Alfred added this*/	
			PROC IMPORT OUT=WORK.out/*&amp;amp;i%substr(&amp;amp;name,7,4)*/  DATAFILE= "&amp;amp;dir/&amp;amp;name" 		
		/*excelout*/			
            DBMS=csv REPLACE;		
			GUESSINGROWS=3000;			
			delimiter='09'x;		
			getnames=no;		
		RUN;			
		proc contents data=out/*&amp;amp;i&amp;amp;name*/ noprint out=data_info /*(keep = name varnum)*/;			
		run;			
					
		 data _null_;			
			set data_info;		
			call symputx(compress("col"||VARNUM),compress(NAME));		
			call symputx("cnt",_n_);		
		run;			
					
					
					
					
					
		/*Alfred test cutting macro into this portion*/			
					
		data _null_;			
		set WORK.out/*&amp;amp;i%substr(&amp;amp;name,7,4)*/ (obs=2);			
			if _n_ = 2 then do;		
			tcnt = 0;		
				%do j=1 %to &amp;amp;cnt;	
					if &amp;amp;&amp;amp;col&amp;amp;j not in ("","Total") /*and (&amp;amp;&amp;amp;col&amp;amp;j in ("T1") or &amp;amp;&amp;amp;col&amp;amp;j in ("T3"))*/ /*Alfred add on the right*/ then do;
					trxm = &amp;amp;&amp;amp;col&amp;amp;j;
					call symputx(compress("trxm"||tcnt),compress(trxm));
					call symputx("tcnt",tcnt);
					tcnt+1;
					end;

					
/*					end;*/
				%end;	
			end;		
		run;	

/*data checkcnt;*/
/*set work.out;*/
/*length blankfilename $50;	*/
	%if %symexist(tcnt) %then %do;
		%put tcnt ada;
	
		 			
		/*Alfred added code below*/					
					
		data test/*&amp;amp;i%substr(&amp;amp;name,7,4)*/ (drop=			
		%do k=1 %to &amp;amp;cnt;			
		&amp;amp;&amp;amp;col&amp;amp;k..			
		%end;			
		);			
					
		length station $10 voltage $10 year 8 month $20 transformer $10			
		Day $20 Date Time MW_Imp MW_Exp MVAR_Imp MVAR_Exp MVA Power_Factor 8;			
		format Time hhmm.;			
		set 			
		out/*&amp;amp;i%substr(&amp;amp;name,7,4)*/ /*out4 out5 out6 out7 out8*/ end=last;			
/*			%do z = 1 %to %sysfunc(dnum(&amp;amp;did));	 */	
/*				out&amp;amp;z. end=last;*/	
/*			%end;*/		
/*		by VAR1 VAR2 VAR3 VAR4 VAR5;	*/		
		retain station voltage year month;	
		/* Check if row 2 is empty or not. If empty then skip*/
/*	if &amp;amp;tcnt eq . then do;*/
/*	%put empty csv name is &amp;amp;name;*/
/*	data blankcsv;*/
/*	proc append base=blankcsv data=&amp;amp;*/
/*	end;*/
/* if &amp;amp;tcnt ne . then do;	*/
		if _n_ = 1 /*&amp;amp;tcnt ne 0*/ then do;			
		station = VAR1;			
		voltage = VAR2;			
		year = input(VAR5,4.);			
		month = VAR3;			
		end;			
		if last /*&amp;amp;tcnt ne 0*/ then do;			
		month = strip(put(intnx('month',input(catt(substr(month,1,3),'1960'),monyy.),1),monname10.));			
		if month = "January" then year = year+1;			
		end;			
		 			
		if _n_ &amp;gt; 4 /*&amp;amp;tcnt ne 0*/ then do;			
		Day = VAR1;			
		Date = VAR2;			
		Time = input(VAR3,time.);			
		%do m=0 %to &amp;amp;tcnt;			
		transformer = "&amp;amp;&amp;amp;trxm&amp;amp;m..";			
		MW_Imp = input(VAR%eval(4+%eval(&amp;amp;m*6)),best32.);			
		MW_Exp = input(VAR%eval(5+%eval(&amp;amp;m*6)),best32.);			
		MVAR_Imp = input(VAR%eval(6+%eval(&amp;amp;m*6)),best32.);			
		MVAR_Exp = input(VAR%eval(7+%eval(&amp;amp;m*6)),best32.);			
		MVA = input(VAR%eval(8+%eval(&amp;amp;m*6)),best32.);			
		if MVA &amp;lt; 0.001 then Power_Factor = 0;			
		else Power_Factor = max(MW_Imp,MW_Exp)/MVA;			
					
		output;			
		%end;			
		end;	
/*	end;	*/
		run;			
/*		Alfred added code below*/			
/*		%do y=2 %to %sysfunc(dnum(&amp;amp;did));*/			
					
/*		data finaltest;*/			
/*		set test;*/			
/*		run;*/			
		proc append base=finaltestone data=test FORCE;			
		run;			
				
/*		data finaltest;*/
/*		run;	*/
/*		proc sql;			*/
/*		select * from finaltest;			*/
/*		quit;			*/
/*		%end;	*/		
					
		/*End of alfred test*/			
					
					
					
					
					
					
					
					
					
					
					
					
					
					
/*				data _tmp;	*/
/*					length dir $512 name $100;*/
/*					dir=symget("dir");*/
/*					name=symget("name");*/
/*					path = catx('/',dir,name);*/
/*					the_name = substr(name,1,find(name,'.')-1);*/
/*				run;	*/
					
/*				proc append base=list data=_tmp force;	*/
/*				run;	*/
/*					*/
/*				quit;	*/
					
/*				proc sql;	*/
/*					drop table _tmp;*/
/*				quit;	*/
				%end;
	%else %do;
		%put tcnt hilang;
		data checkcnt;
/*set work.out;*/
			length blankfilename $50;	
			blankfilename = "&amp;amp;name";

/*SYMGET('file_name');*/
		run;
		proc append base=blankfilelist data=checkcnt force;
		run;
		%LET jump=1;
		%if jump =1 %then %do; CONTINUE;
		%end;
/*		output;*/
	%end;	
			%end;		
		%else %if %qscan(&amp;amp;name,2,.) = %then			
			%do;		
				%list_files(&amp;amp;dir/&amp;amp;name,&amp;amp;ext)	
			%end;		
	%end;				
					
	%let rc=%sysfunc(dclose(&amp;amp;did));				
	%let rc=%sysfunc(filename(filrf));				
%mend list_files;					
				
					

					
%list_files(/sasdata/source/tnbt/BIGTEST,xls);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here i attached the sample code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tom, can you tell me more about "place them on RAM disk" ?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Sep 2018 01:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-collides-after-a-numbers-of-loops/m-p/499337#M132856</guid>
      <dc:creator>imdickson</dc:creator>
      <dc:date>2018-09-27T01:20:25Z</dc:date>
    </item>
  </channel>
</rss>

