<?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: boucle do with 30 minutes increment in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347353#M80209</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;May I suggest setting meta data.

data meta;
  input dsn : $18. start time8. end time8.;
cards4;
sashelp.class 00:00:00 18:00:00
sashelp.iris 18:00:00 24:00:00
sashelp.qrtns 18:00:00 24:00:00
;;;;
run;quit;


* Unlike 'call execute and many macro solutions you
  can set whst ever criteria you want to stop the
  execution of the iteration of a macro or 'call execute';


data _null_;

  set meta;

  put dsn=;
  call symputx('symdsn',dsn);

  do tym=start to end by 180*60;

     rc=dosubl('

        proc sql;
           create
              table tmpdat as
           select
              *
           from
              &amp;amp;symdsn
        ;quit;

        data %scan(&amp;amp;symdsn,1,%str(.));
           retain seq 0;
           set tmpdat;
           seq=_n_;
        run;quit;

        %let Errortext= &amp;amp;syserrortext;
        %let Errorcode= &amp;amp;syserr;

        * you can set your own logic for failure;
        * like 0 obs;

     ');

   if symget('errorcode') ne "0"  then do;
      errortext=symget('errortext');
      put "dataset creation failed for " dsn " stopping parent";
      put "Error message " errortext;
      stop;
   end;

 end;
run;quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 05 Apr 2017 13:35:39 GMT</pubDate>
    <dc:creator>rogerjdeangelis</dc:creator>
    <dc:date>2017-04-05T13:35:39Z</dc:date>
    <item>
      <title>boucle do with 30 minutes increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347307#M80194</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm starting SAS today and i don't find a solution to my issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FInd my code below :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro inter(start, end);&lt;BR /&gt;%do i=&amp;amp;start %to &amp;amp;end %by 30*60;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.MAX_LAST_UPD_TS_DAY AS&lt;BR /&gt;SELECT MAX(T5.LAST_UPD_TS)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM Table5&amp;nbsp; T5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE put(timepart(T5.LAST_UPD_TS),time.) &amp;lt; put(&amp;amp;i,time.);&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;---&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%end;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%inter(start="00:00:00"t, end="18:00:00"t);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The errors code returned :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Required operator not found in expression: &amp;amp;start&lt;BR /&gt;ERROR: The %FROM value of the %DO I loop is invalid.&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:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;end&lt;BR /&gt;ERROR: The %TO value of the %DO I loop is invalid.&lt;BR /&gt;ERROR: The macro INTER will stop executing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for those who will help me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 11:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347307#M80194</guid>
      <dc:creator>Reality696</dc:creator>
      <dc:date>2017-04-05T11:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: boucle do with 30 minutes increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347327#M80199</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137617"&gt;@Reality696&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; am not sure but try like bellow .while caling the start and end time&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%do i=%sysevalf(&amp;amp;start) %to %sysevalf(&amp;amp;end) %by 30*60;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 12:42:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347327#M80199</guid>
      <dc:creator>Madansas7b</dc:creator>
      <dc:date>2017-04-05T12:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: boucle do with 30 minutes increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347331#M80200</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro inter(start, end);
%do i=%sysevalf(&amp;amp;start) %to %sysevalf(&amp;amp;end) %by %eval(30*60);

proc sql;
   create
      table dlass as
   select
      *
   from
      sashelp.class
;quit;

%end;
%mend;

%inter(start="00:00:00"t, end="18:00:00"t);

NOTE: Table WORK.DLASS created, with 19 rows and 5 columns.

NOTE: PROCEDURE SQL used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds


NOTE: Table WORK.DLASS created, with 19 rows and 5 columns.

NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: Table WORK.DLASS created, with 19 rows and 5 columns.

NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

...


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Apr 2017 12:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347331#M80200</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-04-05T12:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: boucle do with 30 minutes increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347353#M80209</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;May I suggest setting meta data.

data meta;
  input dsn : $18. start time8. end time8.;
cards4;
sashelp.class 00:00:00 18:00:00
sashelp.iris 18:00:00 24:00:00
sashelp.qrtns 18:00:00 24:00:00
;;;;
run;quit;


* Unlike 'call execute and many macro solutions you
  can set whst ever criteria you want to stop the
  execution of the iteration of a macro or 'call execute';


data _null_;

  set meta;

  put dsn=;
  call symputx('symdsn',dsn);

  do tym=start to end by 180*60;

     rc=dosubl('

        proc sql;
           create
              table tmpdat as
           select
              *
           from
              &amp;amp;symdsn
        ;quit;

        data %scan(&amp;amp;symdsn,1,%str(.));
           retain seq 0;
           set tmpdat;
           seq=_n_;
        run;quit;

        %let Errortext= &amp;amp;syserrortext;
        %let Errorcode= &amp;amp;syserr;

        * you can set your own logic for failure;
        * like 0 obs;

     ');

   if symget('errorcode') ne "0"  then do;
      errortext=symget('errortext');
      put "dataset creation failed for " dsn " stopping parent";
      put "Error message " errortext;
      stop;
   end;

 end;
run;quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Apr 2017 13:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347353#M80209</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-04-05T13:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: boucle do with 30 minutes increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347385#M80230</link>
      <description>&lt;P&gt;Starting with macros and not having an understanding of the base SAS language and procedures is almost gauranteed to have much confusion. Macros are intended to generate base code. If you do not know which code you want to generate&amp;nbsp;in the proper forms&amp;nbsp;then macros are going to slow down learning.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance, your loop is only going to have a data set for the End value. You overwrite the output set for every value in the do loop leaving only the last one.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 14:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347385#M80230</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-05T14:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: boucle do with 30 minutes increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347430#M80249</link>
      <description>Exactly what i saw and trying to solve it, adding a new condition to insert the data instead of erasing it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 05 Apr 2017 15:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347430#M80249</guid>
      <dc:creator>Reality696</dc:creator>
      <dc:date>2017-04-05T15:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: boucle do with 30 minutes increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347431#M80250</link>
      <description>&lt;P&gt;Thank you for the replies guys, it help me &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 15:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347431#M80250</guid>
      <dc:creator>Reality696</dc:creator>
      <dc:date>2017-04-05T15:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: boucle do with 30 minutes increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347629#M80345</link>
      <description>&lt;P&gt;I have another issue since yesterday and i don't have so much time to learn correctly as it's for work (and have no formation on this langage basis)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code below :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro inter(start, end);
%do i=%sysevalf(&amp;amp;start) %to %sysevalf(&amp;amp;end) %by %eval(30*60);


PROC SQL

CREATE TABLE WORK.T1

---

QUIT;


PROC SQL

CREATE TABLE WORK.T2

---

QUIT;


%if &amp;amp;i eq 0 %then
    %do;
 
   PROC SQL;
    CREATE TABLE WORK.T3 as
    SELECT a.BD, a.SDEB, a.SCRED, a.TYPE, a.STATUS,
    (CASE WHEN b.SETT = . THEN a.SETT
      ELSE a.SETT-b.SETT END) As SETT FORMAT=EUROX20.2, a.REMAIN FORMAT=EUROX20.2, a.NB, put(&amp;amp;i,time.) as TS
    FROM WORK.T1 A
        LEFT JOIN WORK.T2 B on (a.BD=b.BD and a.type=b.type and a.status=b.status);
    QUIT;
    %end;
%else
    %do;

    PROC SQL;
    INSERT INTO TABLE WORK.T3
    SELECT a.BD, a.SDEB, a.SCRED, a.TYPE, a.STATUS,
    (CASE WHEN b.SETT = . THEN a.SETT
      ELSE a.SETT-b.SETT END) FORMAT=EUROX20.2, a.REMAIN FORMAT=EUROX20.2, a.NB, put(&amp;amp;i,time.)
    FROM WORK.T1 A
        LEFT JOIN WORK.T2 B on (a.BD=b.BD and a.type=b.type and a.status=b.status);
    QUIT;

    %end;

%end;
%mend;

%inter(start="00:00:00"t, end="01:00:00"t);&lt;/PRE&gt;&lt;P&gt;Create Table work fine but i can't succeed to insert following data =(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the log below :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;NOTE: Line generated by the invoked macro "INTER".
176           PROC SQL;  INSERT INTO TABLE WORK.NTS_GLOBAL_FINAL (BUSINESS_DATE, SYSENTDEB, SYSENTCRED, TYPE, STATUS,SETTLED,
                                           ____
                                           79
176      ! REMAINING, NUMBER, TS)  SELECT a.BUSINESS_DATE, a.SYSENTDEB, a.SYSENTCRED, a.TYPE, a.STATUS,   (CASE WHEN b.SETTLED = .
176      ! THEN a.SETTLED
ERROR 79-322: Expecting a SELECT.

NOTE: Line generated by the invoked macro "INTER".
176           PROC SQL;  INSERT INTO TABLE WORK.NTS_GLOBAL_FINAL (BUSINESS_DATE, SYSENTDEB, SYSENTCRED, TYPE, STATUS,SETTLED,
                                           ____
                                           202
176      ! REMAINING, NUMBER, TS)  SELECT a.BUSINESS_DATE, a.SYSENTDEB, a.SYSENTCRED, a.TYPE, a.STATUS,   (CASE WHEN b.SETTLED = .
176      ! THEN a.SETTLED
ERROR 202-322: The option or parameter is not recognized and will be ignored.&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Thank you for your help.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;PS: i'll will ask for a formation on SAS&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 09:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347629#M80345</guid>
      <dc:creator>Reality696</dc:creator>
      <dc:date>2017-04-06T09:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: boucle do with 30 minutes increment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347734#M80403</link>
      <description>&lt;P&gt;My bad, it's just a syntax error =(&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 14:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/boucle-do-with-30-minutes-increment/m-p/347734#M80403</guid>
      <dc:creator>Reality696</dc:creator>
      <dc:date>2017-04-06T14:14:12Z</dc:date>
    </item>
  </channel>
</rss>

