<?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: do while is not working in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973028#M46121</link>
    <description>&lt;P&gt;Agreeing with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, there is no point in using macros for this task. So &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;what is the real problem you are trying to solve?&lt;/P&gt;</description>
    <pubDate>Thu, 21 Aug 2025 09:54:42 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2025-08-21T09:54:42Z</dc:date>
    <item>
      <title>do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973009#M46114</link>
      <description>&lt;P&gt;the do while is not working.&lt;/P&gt;
&lt;P&gt;What's wrong ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data paths;
     length path $200;
     input path $;
     datalines;
/dwh_actuariat/sasprocess/prodmens/HYFIprep/output
/dwh_actuariat/sasprocess/prodmens/HYFIp/output
;
run;
%macro process;
proc sql noprint;
     select path into :path_list separated by ' '
     from paths;
quit;

%put &amp;amp;=path_list;


%let i = 1;
%do %while (%scan(&amp;amp;path_list, &amp;amp;i. , ' ') ne '');
     %let current_path = %scan(&amp;amp;path_list, &amp;amp;i. , ' ');
     %put &amp;amp;=current_path;
     %let i = %eval(&amp;amp;i. + 1);
%end;


%mend process;
%process;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Aug 2025 21:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973009#M46114</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-08-20T21:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973012#M46115</link>
      <description>&lt;PRE&gt;data paths;
     length path $200;
     input path $;
     datalines;
/dwh_actuariat/sasprocess/prodmens/HYFIprep/output
/dwh_actuariat/sasprocess/prodmens/HYFIp/output
;
run;
%macro process;
proc sql noprint;
     select path into :path_list separated by ' '
     from paths;
quit;

%put &amp;amp;=path_list;


%let i = 1;
%do %while (&lt;STRONG&gt;%qscan(&amp;amp;path_list, &amp;amp;i. ,%str( )) ne&lt;/STRONG&gt; );
     %let current_path = %scan(&amp;amp;path_list, &amp;amp;i. ,&lt;STRONG&gt; %str( )&lt;/STRONG&gt;);
     %put &amp;amp;=current_path;
     %let i = %eval(&amp;amp;i. + 1);
%end;


%mend process;
%process;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Aug 2025 01:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973012#M46115</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-08-21T01:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973014#M46116</link>
      <description>&lt;P&gt;Why did you tell SQL to use space as the delimiter and tell %SCAN() to also include single quote as a delimiter?&amp;nbsp; &amp;nbsp;And why did you compare the value to something that does contain single quote characters? That will never match as the result of the %SCAN() function could never contain any single quotes since they are being used as delimiters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note since you want to use %SCAN() to split the macro variable it will work better to use some character that cannot appear in a path as the delimiter, such as a | character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also SAS will not like those / characters in the strings generated by the %SCAN() call.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;PATH_LIST=/dwh_actuariat/sasprocess/prodmens/HYFIprep/output /dwh_actuariat/sasprocess/prodmens/HYFIp/output
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
       %scan(&amp;amp;path_list, &amp;amp;i. ,  ) ne
ERROR: The condition in the %DO %WHILE loop, %scan(&amp;amp;path_list, &amp;amp;i. , &amp;#1; &amp;#2;) ne, yielded an invalid or missing value, .  The macro
       will stop executing.
ERROR: The macro PROCESS will stop executing.

&lt;/PRE&gt;
&lt;P&gt;If you want to get your complex looping code to work make sure to use the right delimiter and compare to and actual empty value and use macro quoting to protect the value of the path from confusing the %EVAL() used by the %WHILE().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do %while (%qscan(&amp;amp;path_list, &amp;amp;i. , %str( )) ne );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;But why would you use such a complex loop when you can just use a NORMAL iterative do loop?&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro process;
%local path_list i n current_path;
proc sql noprint;
  select path into :path_list separated by '|'
  from paths;
quit;
%let n=&amp;amp;sqlobs;

%do i=1 %to &amp;amp;n;
  %let current_path = %scan(&amp;amp;path_list, &amp;amp;i. ,|);
  %put &amp;amp;=i &amp;amp;=current_path;
%end;
%mend process;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results&lt;/P&gt;
&lt;PRE&gt;I=1 CURRENT_PATH=/dwh_actuariat/sasprocess/prodmens/HYFIprep/output
I=2 CURRENT_PATH=/dwh_actuariat/sasprocess/prodmens/HYFIp/output
&lt;/PRE&gt;
&lt;P&gt;And if you want to loop over a delimited list where you don't know the number of items in advance just count them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 %to %sysfunc(countw(&amp;amp;path_list,|));
  %let current_path = %scan(&amp;amp;path_list, &amp;amp;i. ,|);
  %put &amp;amp;=i &amp;amp;=current_path;
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Aug 2025 16:33:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973014#M46116</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-08-21T16:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973016#M46117</link>
      <description>&lt;P&gt;From my point of view the first error is moving data from a dataset into macro variables, which is not necessary in most cases.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 06:12:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973016#M46117</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2025-08-21T06:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973017#M46118</link>
      <description>&lt;P&gt;How about using &lt;STRONG&gt;&lt;A href="https://github.com/SASPAC/macroarray" target="_self"&gt;macroArray packge&lt;/A&gt;&lt;/STRONG&gt;&amp;nbsp;and create a macro variable array?&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/SASPAC/macroarray/blob/main/macroarray.md" target="_self"&gt;&lt;STRONG&gt;Documentation&lt;/STRONG&gt;&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)&amp;nbsp;&lt;STRONG&gt;&lt;A href="https://www.lexjansen.com/pharmasug/2024/AP/PharmaSUG-2024-AP-108.pdf" target="_self"&gt;Article&lt;/A&gt;&lt;/STRONG&gt; describing the package.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* load package to your SAS session */
%loadPackage(macroArray)


/* data */
data paths;
     length path $200;
     input path $;
     datalines;
/dwh_actuariat/sasprocess/prodmens/HYFIprep/output
/dwh_actuariat/sasprocess/prodmens/HYFIp/output
;
run;


/* create m.v.a. Path */
%array(ds=paths,vars=path,macarray=Y)

/*
optionally preview:
%put %do_over(path);
*/

/* use macro variable array  */
%macro test(i);

%do i = 1 %to &amp;amp;i.;
  %put &amp;amp;=i. #%path(&amp;amp;i.)#; /* call %path() macro to get values one by one */
%end;

%mend;

%test(&amp;amp;pathN.) /* pathN macro variable keep size */

/* clean up */
%deleteMacArray(path,macarray=Y)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1
2
3    data paths;
4         length path $200;
5         input path $;
6         datalines;

NOTE: The data set WORK.PATHS has 2 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.00 seconds
      memory              404.96k
      OS Memory           25908.00k
      Timestamp           08/21/2025 09:24:43 AM
      Step Count                        289  Switch Count  0


9    ;
10   run;
11
12
13   /* create */
14   %array(ds=paths,vars=path,macarray=Y)
NOTE:[ARRAY] 2 macrovariables created
15
16   /*
17   optionally preview:
18   %put %do_over(path);
19   */
20
21   /* use macro variable array  */
22   %macro test(i);
23
24   %do i = 1 %to &amp;amp;i.;
25     %put &amp;amp;=i. #%path(&amp;amp;i.)#;
26   %end;
27
28   %mend;
29
30   %test(&amp;amp;pathN.)
I=1 #/dwh_actuariat/sasprocess/prodmens/HYFIprep/output#
I=2 #/dwh_actuariat/sasprocess/prodmens/HYFIp/output#
31
32   /* clean up */
33   %deleteMacArray(path,macarray=Y)
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;P.S. How to install MacroArray package?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp;Create a directory of your convenience, for example:&lt;/P&gt;
&lt;UL dir="auto"&gt;
&lt;LI&gt;&lt;CODE&gt;C:\users\myuser\Desktop\Packages&lt;/CODE&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;2) In your SAS session, run the following line of code:&lt;/P&gt;
&lt;DIV class="highlight highlight-source-sas notranslate position-relative overflow-auto" dir="auto"&gt;
&lt;PRE&gt;filename packages "C:\users\myuser\Desktop\Packages";&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;For Linux change the path accordingly&lt;/P&gt;
&lt;P&gt;3)&amp;nbsp;&lt;SPAN&gt;T&lt;/SPAN&gt;o install the SAS Packages Framework, execute the code (only one time):&lt;/P&gt;
&lt;DIV class="highlight highlight-source-sas notranslate position-relative overflow-auto" dir="auto"&gt;
&lt;PRE&gt;&lt;SPAN class="pl-c"&gt;/* enable a temporary version of the framework */&lt;/SPAN&gt;
&lt;SPAN class="pl-c1"&gt;filename&lt;/SPAN&gt; SPFinit url 
 &lt;SPAN class="pl-s"&gt;"https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas"&lt;/SPAN&gt;;      
&lt;SPAN class="pl-k"&gt;&lt;SPAN class="pl-c1"&gt;%include&lt;/SPAN&gt; &lt;SPAN class="pl-en"&gt;SPFinit&lt;/SPAN&gt;&lt;/SPAN&gt;; 

&lt;SPAN class="pl-c"&gt;/* install the framework */&lt;/SPAN&gt;
%installPackage(SPFinit)

&lt;SPAN class="pl-c1"&gt;filename&lt;/SPAN&gt; SPFinit clear;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;4) To install the package&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;macroArray&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;run the following code:&lt;/P&gt;
&lt;DIV class="highlight highlight-source-sas notranslate position-relative overflow-auto" dir="auto"&gt;
&lt;PRE&gt;%installPackage(macroArray)&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5)&amp;nbsp;In order to use the SPF and packages in a SAS session, they must be enabled and loaded first. This is very straightforward, all we need to do is to assign the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;packages&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;filename to the packages directory, then include the framework code, and load a package we need. To do so execute 3 lines of code:&lt;/P&gt;
&lt;DIV class="highlight highlight-source-sas notranslate position-relative overflow-auto" dir="auto"&gt;
&lt;PRE&gt;filename packages "/path/to/my/packages";
%include packages(SPFinit.sas);
%loadPackage(macroArray)&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See &lt;A href="https://github.com/yabwon/HoW-SASPackages/blob/main/Share%20your%20code%20with%20SAS%20Packages%20-%20a%20Hands-on-Workshop.md" target="_self"&gt;&lt;STRONG&gt;SAS packages tutorial&lt;/STRONG&gt;&lt;/A&gt;&amp;nbsp;for more details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 07:25:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973017#M46118</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2025-08-21T07:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973025#M46119</link>
      <description>&lt;P&gt;In its current form, the macro does nothing but write values to the log, which can easily be achieved in a single DATA step without any macro language.&lt;/P&gt;
&lt;P&gt;What is your real task?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 08:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973025#M46119</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-08-21T08:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973027#M46120</link>
      <description>Kurt,&lt;BR /&gt;I just copy the code from OP and fixed it.&lt;BR /&gt;I have no idea about what is OP's intention.</description>
      <pubDate>Thu, 21 Aug 2025 09:30:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973027#M46120</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-08-21T09:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973028#M46121</link>
      <description>&lt;P&gt;Agreeing with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, there is no point in using macros for this task. So &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;what is the real problem you are trying to solve?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 09:54:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973028#M46121</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-08-21T09:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973031#M46122</link>
      <description>&lt;P&gt;Oh, sorry, that should have been a reply to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;'s original post.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 11:34:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973031#M46122</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2025-08-21T11:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973046#M46123</link>
      <description>&lt;P&gt;Well I want to use the macro process to passed as parameter the two different paths.&amp;nbsp; Then I will replace the %put statement by another macro function that is loading all the txt files into that folder into a sas dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 17:49:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973046#M46123</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-08-21T17:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973047#M46124</link>
      <description>I will replace the %put by another macro function.</description>
      <pubDate>Thu, 21 Aug 2025 17:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973047#M46124</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-08-21T17:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973048#M46125</link>
      <description>Why did you replace the %scan by %pscan and the '' by %str() and ne )&lt;BR /&gt;&lt;BR /&gt;Please explain.&lt;BR /&gt;Your script work perfectly</description>
      <pubDate>Thu, 21 Aug 2025 17:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973048#M46125</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-08-21T17:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973050#M46126</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Why did you replace the %scan by %pscan and the '' by %str() and ne )&lt;BR /&gt;&lt;BR /&gt;Please explain.&lt;BR /&gt;Your script work perfectly&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;%QSCAN() adds macro quoting to the path so that %EVAL() does not see the / as division symbols.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do not need to enclose strings in quotes for the macro processor.&amp;nbsp; The reason you need the quotes in SAS code is so SAS knows what to treat as strings and what to treat as variable names or keywords.&amp;nbsp; But to the macro processor everything is a string. So the quotes become part of the string.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 18:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973050#M46126</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-08-21T18:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973051#M46127</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76331"&gt;@alepage&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Well I want to use the macro process to passed as parameter the two different paths.&amp;nbsp; Then I will replace the %put statement by another macro function that is loading all the txt files into that folder into a sas dataset.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So skip the macro and the macro variables and just use a data step to generate the calls to the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if your macro is named %MYMACRO() and takes the path as the first positional argument you could generate one call to the macro for each observation in the data PATHS with this data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set paths;
  call execute(cats('%nrstr(%mymacro)(',path,')'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Aug 2025 18:30:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973051#M46127</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-08-21T18:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973052#M46128</link>
      <description>&lt;P&gt;for Mr. Miller here's my complete script&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data paths;
     length path $200;
     input path $;
     datalines;
/dwh_actuariat/sasprocess/prodmens/HYFIprep/output
/dwh_actuariat/sasprocess/prodmens/HYFIp/output
;
run;

/************************************************************/

%macro readfile(path,fname,suffix);
    DATA &amp;amp;fname.;
        INFILE "&amp;amp;path./&amp;amp;fname..&amp;amp;suffix";
        INPUT Cie $ 1
              province $ 2-3
              branch   $ 4-7
              priorcur $ 8
               polsrc  $ 9
               mois    $ 10-15
               lob     $ 16-23
               Trans   $ 24-26
               WP       27-41
               EP       42-56
               EU       57-71
               WU       72-86
               POLCNT   87-102
               POLEARN  103-117
               UW_CIE   $ 118
               DIST_CIE  $ 119
               OB_IND    $ 120-124
               BROKER_GROUP_IND $ 125-126
               GCNA_BRANCH      $ 127-128               
               POLICY_CATEGORY  $ 129
               NETWORK_PROVIDER $ 130-134
               AFFINITY_IND     $ 135
;
    RUN;
%mend readfile;
/*******************************************************/
%macro readtxtfile;
%let yearmin=2024;
%let yearmax=2025;
%let prefix=HyFIPrems;
%let suffix=txt;
%let path=/dwh_actuariat/sasprocess/prodmens/HYFIprep/output;

%do year = &amp;amp;yearmin %to &amp;amp;yearmax;
     %if &amp;amp;year. ne &amp;amp;yearmax. %then %let maxmonth=12; 
     %else %let maxmonth=7;
     %do month =01 %to &amp;amp;maxmonth.;
     %let formatted_month = %sysfunc(putn(&amp;amp;month, Z2.));
     %let fname=&amp;amp;prefix.&amp;amp;year.&amp;amp;formatted_month.;
          %put &amp;amp;fname..&amp;amp;suffix.;
          %readfile(&amp;amp;path,&amp;amp;fname,&amp;amp;suffix);

          PROC APPEND BASE=&amp;amp;prefix. DATA=&amp;amp;fname.;
          RUN;
     %end;
%end;

%mend readtxtfile;
/******************************************/
*%readtxtfile;

%macro readtxtfile2(path);
%let yearmin=2025;
%let yearmax=2025;
%let minmonth=1;
%let maxmonth=7;

%let prefix=HyFIPrems;
%let suffix=txt;


%do year = &amp;amp;yearmin %to &amp;amp;yearmax;     
     %do month =&amp;amp;minmonth. %to &amp;amp;maxmonth.;
     %let formatted_month = %sysfunc(putn(&amp;amp;month, Z2.));
     %let fname=&amp;amp;prefix.&amp;amp;year.&amp;amp;formatted_month.;
          %put &amp;amp;fname..&amp;amp;suffix.;
          
          %readfile(&amp;amp;path,&amp;amp;fname,&amp;amp;suffix);

          %let substring=prep;


          %if %sysfunc(find(&amp;amp;path. , &amp;amp;substring.)) &amp;gt; 0 %then 
          %do;
               PROC APPEND BASE=&amp;amp;prefix. DATA=&amp;amp;fname.;
               RUN;
          %end;
          %else
          %do;
               PROC APPEND BASE=&amp;amp;prefix._org DATA=&amp;amp;fname.;
               RUN;
          %end; 


          
     %end;
%end;

%mend readtxtfile2;
%macro process;
proc sql noprint;
     select path into :path_list separated by ' '
     from paths;
quit;

%put &amp;amp;=path_list;


%let i = 1;
%do %while (%qscan(&amp;amp;path_list, &amp;amp;i. ,%str( )) ne );
     %let current_path = %scan(&amp;amp;path_list, &amp;amp;i. , %str( ));
     %put &amp;amp;=current_path;
     %readtxtfile2(&amp;amp;current_path);

     %let i = %eval(&amp;amp;i. + 1);
%end;


%mend process;
%process;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Aug 2025 18:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973052#M46128</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-08-21T18:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973054#M46129</link>
      <description>&lt;P&gt;Macro programming is fun, but don't use it when it is not needed.&lt;/P&gt;
&lt;P&gt;Looks to me like you want to run this data step to create your two output datasets.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data paths;
  infile datalines truncover;
  input path $200.;
datalines;
/dwh_actuariat/sasprocess/prodmens/HYFIprep/output
/dwh_actuariat/sasprocess/prodmens/HYFIp/output
;

%let prefix=HyFIPrems;
%let substring=prep;

data &amp;amp;prefix. &amp;amp;prefix._org ;
  set paths;
  do year=2025 to 2025 ;
    do month = 1 to 7 ;
      length fname $256 ;
      fname=catx('/',path,cats("&amp;amp;prefix",year,put(month,z2.),'.txt'));
      infile text filevar=fname truncover end=eof; 
      do while(not eof);
        INPUT Cie $ 1
              province $ 2-3
              branch   $ 4-7
              priorcur $ 8
              polsrc  $ 9
              mois    $ 10-15
              lob     $ 16-23
              Trans   $ 24-26
              WP       27-41
              EP       42-56
              EU       57-71
              WU       72-86
              POLCNT   87-102
              POLEARN  103-117
              UW_CIE   $ 118
              DIST_CIE  $ 119
              OB_IND    $ 120-124
              BROKER_GROUP_IND $ 125-126
              GCNA_BRANCH      $ 127-128               
              POLICY_CATEGORY  $ 129
              NETWORK_PROVIDER $ 130-134
              AFFINITY_IND     $ 135
        ;
        if find(path,"&amp;amp;substring") then output  &amp;amp;prefix.;
        else output &amp;amp;prefix._org ;
      end;
    end;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 19:30:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973054#M46129</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-08-21T19:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973081#M46130</link>
      <description>&lt;P&gt;1)Actually, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; has already answered your question.&lt;BR /&gt;The secret hided in operator "NE".&lt;BR /&gt;When sas meet "NE" ,would put %eval() around "/dwh_actuariat/sasprocess/prodmens/HYFIp/output"&lt;BR /&gt;and since "/" is a divided operator in sas ,sas would take it as a divided operator, and lead to this error.&lt;BR /&gt;Here I use %QSCAN() is to mask "/" operator to avoid this error as Tom show you detailly .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2)A white blank is&amp;nbsp; a special character in MACRO language, so I use %str( ) to mask it to let MACRO know it as I use %qscan() to mask "/“ divided operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3)As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; pointed out MACRO take everything as a STRING , you don't need to put quote around it just leave it as a blank . Otherwise, MACRO would take it as "a blank", not a NULL character(empty).&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2025 01:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973081#M46130</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-08-22T01:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: do while is not working</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973118#M46131</link>
      <description>Yes you are right, that will do the same</description>
      <pubDate>Fri, 22 Aug 2025 13:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/do-while-is-not-working/m-p/973118#M46131</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2025-08-22T13:37:38Z</dc:date>
    </item>
  </channel>
</rss>

