<?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: loop scan dates values coming from variable of table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783895#M250067</link>
    <description>&lt;P&gt;Please re-format your problem description to make it readable. Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Dec 2021 11:53:41 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-12-03T11:53:41Z</dc:date>
    <item>
      <title>loop scan dates values coming from variable of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783893#M250066</link>
      <description>Hello,

data have;
input jour DDMMYY10. ;
format jour DDMMYY10. ;
datalines;
01/01/2022
02/01/2022
03/01/2022
04/01/2022
05/01/2022
06/01/2022
07/01/2022
08/01/2022
09/01/2022
10/01/2022
11/01/2022
;
proc sql;
	select distinct jour into :liste_jour separated by ' ' from have ;
quit ;


%put &amp;amp;liste_jour;

by executing this code above the result is 01/01/2022 02/01/2022 03/01/2022 04/01/2022 05/01/2022 06/01/2022 07/01/2022 08/01/2022 09/01/2022 10/01/2022 11/01/2022
But my problem is when I try to get each date value for loop like this below; 
the result is not corret because it is 01 and 01 and 2021...
thanks in advance for your help
kind regards
Nass
%macro mc_boucle_surlesjours ;
%local i next_jour;
%let i=1;
	%do %while (%scan(&amp;amp;liste_jour, &amp;amp;i) ne "");
 		%let next_jour = %scan(&amp;amp;liste_jour, &amp;amp;i);
		%put --&amp;gt;&amp;amp;next_jour ;
		%let i = %eval(&amp;amp;i + 1);
	%end ;

%mend ;

%mc_boucle_surlesjours ;</description>
      <pubDate>Fri, 03 Dec 2021 11:42:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783893#M250066</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2021-12-03T11:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: loop scan dates values coming from variable of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783895#M250067</link>
      <description>&lt;P&gt;Please re-format your problem description to make it readable. Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 11:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783895#M250067</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-03T11:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: loop scan dates values coming from variable of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783904#M250072</link>
      <description>I have a table with a variable "day" that containes dates values like "01/01/022" "02/01/2022" "03/01/2022" …
I would that a macro variable gets each values by usinf a loop</description>
      <pubDate>Fri, 03 Dec 2021 12:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783904#M250072</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2021-12-03T12:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: loop scan dates values coming from variable of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783907#M250073</link>
      <description>&lt;P&gt;Repeating:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please re-format your problem description to make it readable.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 12:41:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783907#M250073</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-03T12:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: loop scan dates values coming from variable of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783911#M250075</link>
      <description>I would like to write a loop step with the objectif is to put into a variable the values
01/01/2022 for iteration 1
02/01/2022 for iteration 2
03/01/2022 for iteration 3
04/01/2022 ...
05/01/2022
06/01/2022
07/01/2022
08/01/2022
09/01/2022
10/01/2022
11/01/2022 for the last iteration</description>
      <pubDate>Fri, 03 Dec 2021 12:55:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783911#M250075</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2021-12-03T12:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: loop scan dates values coming from variable of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783912#M250076</link>
      <description>by executing this

%macro mc_boucle_surlesjours ;
%local i next_jour;
%let i=1;
	%do %while (%scan(&amp;amp;liste_jour, &amp;amp;i) ne );
 		%let next_jour = %scan(&amp;amp;liste_jour, &amp;amp;i);
		%put --&amp;gt;&amp;amp;next_jour ;
		%let i = %eval(&amp;amp;i + 1);
	%end ;

%mend ;

%mc_boucle_surlesjours ;


the result is
--&amp;gt;01
--&amp;gt;01
--&amp;gt;2022
--&amp;gt;02
--&amp;gt;01
--&amp;gt;2022
--&amp;gt;03
--&amp;gt;01
--&amp;gt;2022
--&amp;gt;04
--&amp;gt;01
--&amp;gt;2022
--&amp;gt;05
--&amp;gt;01
--&amp;gt;2022
--&amp;gt;06
--&amp;gt;01
--&amp;gt;2022
--&amp;gt;07
...</description>
      <pubDate>Fri, 03 Dec 2021 12:57:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783912#M250076</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2021-12-03T12:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: loop scan dates values coming from variable of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783913#M250077</link>
      <description>&lt;P&gt;ok I found the solution.see below. in the scan I forgot to specify the separator space. this code below works as I intended&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mc_boucle_surlesjours ;
 %local i next_jour;
 %let i=1;
 %do %while (%scan(&amp;amp;liste_jour, &amp;amp;i, " ") ne );
   %let next_jour = %scan(&amp;amp;liste_jour, &amp;amp;i, " ");
   %put --&amp;gt;&amp;amp;next_jour ;
   %let i = %eval(&amp;amp;i + 1);
 %end ; 
%mend ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Dec 2021 14:01:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783913#M250077</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2021-12-03T14:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: loop scan dates values coming from variable of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783914#M250078</link>
      <description>&lt;P&gt;Read your post and then look at this:&lt;/P&gt;
&lt;PRE&gt;data have;
 input jour DDMMYY10. ;
 format jour DDMMYY10. ;
 datalines;
01/01/2022
02/01/2022
03/01/2022
04/01/2022
05/01/2022
06/01/2022
07/01/2022
08/01/2022
09/01/2022
10/01/2022
11/01/2022
;
 proc sql noprint;
 select distinct jour into :liste_jour separated by ' ' from have ;
 quit ;
 %put &amp;amp;liste_jour;


%macro mc_boucle_surlesjours ;
 %local i next_jour;
 %do i = 1 %to %sysfunc(countw(&amp;amp;liste_jour,%str( )));
 
    %let next_jour = %scan(&amp;amp;liste_jour, &amp;amp;i,%str( ));
    %put --&amp;gt;&amp;amp;next_jour ;

 %end ;
 %mend ;
 %mc_boucle_surlesjours ;
 &lt;/PRE&gt;
&lt;P&gt;That is part of what is meant by "reformat your post".&lt;/P&gt;
&lt;P&gt;The above does part of what I think you want.&lt;/P&gt;
&lt;P&gt;Problem: using SCAN by default will treat the / character as delimiter between words. The fix above forces a space into the parameters for Countw and Scan functions as the only delimiter.&lt;/P&gt;
&lt;P&gt;Or depending on how you expect to use those dates do not apply a format. Really the only time a macro Date value should be formatted is when it is read my humans such as in a title, footnote or possibly a file name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do not format the date variable you will get the numbers that represent the date and can be used if comparisons or other date related functions and would not need the forced space from the %Str&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 13:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783914#M250078</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-12-03T13:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: loop scan dates values coming from variable of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783921#M250079</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/147725"&gt;@Nasser_DRMCP&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;by executing this %macro mc_boucle_surlesjours ; %local i next_jour; %let i=1; %do %while (%scan(&amp;amp;liste_jour, &amp;amp;i) ne ); %let next_jour = %scan(&amp;amp;liste_jour, &amp;amp;i); %put --&amp;gt;&amp;amp;next_jour ; %let i = %eval(&amp;amp;i + 1); %end ; %mend ; %mc_boucle_surlesjours ; the result is --&amp;gt;01 --&amp;gt;01 --&amp;gt;2022 --&amp;gt;02 --&amp;gt;01 --&amp;gt;2022 --&amp;gt;03 --&amp;gt;01 --&amp;gt;2022 --&amp;gt;04 --&amp;gt;01 --&amp;gt;2022 --&amp;gt;05 --&amp;gt;01 --&amp;gt;2022 --&amp;gt;06 --&amp;gt;01 --&amp;gt;2022 --&amp;gt;07 ...&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do not post code as plain unformatted text. Post code in the box that appears when you click on the "Insert SAS Code" icon. You may have found the correct answer, but again, I ask you to re-format it to be readable by using the "Insert SAS Code" icon, for the benefit of everyone else.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 13:19:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783921#M250079</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-03T13:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: loop scan dates values coming from variable of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783923#M250080</link>
      <description>thank you very much
very clear and very interesting</description>
      <pubDate>Fri, 03 Dec 2021 13:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-scan-dates-values-coming-from-variable-of-table/m-p/783923#M250080</guid>
      <dc:creator>Nasser_DRMCP</dc:creator>
      <dc:date>2021-12-03T13:17:56Z</dc:date>
    </item>
  </channel>
</rss>

