<?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: How to debug Invalid Do Loop  control - Concomitant Medication Use in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764779#M242252</link>
    <description>&lt;P&gt;The error message is very clear. You have missing values. The LOG should show you the missing values.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;19    data have;
20      input ID  DRUG $  START_DT :mmddyy. DAYS_SUPP END_DT :mmddyy.;
21      format start_dt end_dt yymmdd10.;
22    datalines;

NOTE: Invalid data for START_DT in line 24 5-11.
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
24          1 B 5/60/09 30  6/5/09
ID=1 DRUG=B START_DT=. DAYS_SUPP=30 END_DT=2009-06-05 _ERROR_=1 _N_=2
NOTE: The data set WORK.HAVE has 2 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


22  !           ;
25    ;
26
27    data days;
28      set have;
29      dum = 1;
30      do day = start_dt to end_dt;
31        output;
32      end;
33      format day yymmdd10.;
34    run;

ERROR: Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero, or
       invalid.
ID=1 DRUG=B START_DT=. DAYS_SUPP=30 END_DT=2009-06-05 dum=1 day=. _ERROR_=1 _N_=2
&lt;/PRE&gt;
&lt;P&gt;You can trap those cases and not execute the DO loop when there are missing values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if n(start_dt,end_dt)=2 then do day = start_dt to end_dt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Aug 2021 01:31:20 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-08-30T01:31:20Z</dc:date>
    <item>
      <title>How to debug Invalid Do Loop  control - Concomitant Medication Use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764680#M242229</link>
      <description>&lt;P&gt;Hello, I have found a solution to code concomitant medication use in SAS, but my code runs with error. Any suggestions on how to proceed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;ERROR: Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero, or invalid.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
input ID	DRUG $	START_DT :mmddyy.	DAYS_SUPP	END_DT :mmddyy.;
datalines;;
1	A	2/17/10	30	3/19/10
1	B	5/6/09	30	6/5/09
1	C	7/9/11	60	9/7/11
1	E	3/1/10	90	5/30/10
1	B	1/1/09	90	4/1/09
1	D	2/1/09	30	3/3/09
1	C	5/6/12	90	8/4/12
2	B	4/1/12	60	5/31/12
2	A	7/1/10	30	7/31/10
2	C	8/3/10	90	11/1/10
2	D	11/1/13	90	1/30/14
2	E	12/5/13	90	3/5/14
2	A	2/1/11	90	5/2/11
2   F   12/16/13 30 1/14/14
;

data days;
set have;
dum = 1;
do day = start_dt to end_dt;&lt;BR /&gt;by id;
    output;
    end;
format day yymmdd10.;
keep id drug day;
run;

proc sort data=days; by id day drug; run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 14:21:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764680#M242229</guid>
      <dc:creator>macro_2349</dc:creator>
      <dc:date>2021-08-29T14:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug Invalid Do Loop  control - Concomitant Medication Use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764704#M242231</link>
      <description>&lt;P&gt;Your code does NOT throw an ERROR.&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 15:11:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764704#M242231</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-08-29T15:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug Invalid Do Loop  control - Concomitant Medication Use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764708#M242233</link>
      <description>&lt;P&gt;Whenever you get an error in the log, show us the &lt;STRONG&gt;ENTIRE&lt;/STRONG&gt; log for the data step with the error, that's every single line in the log for the data step with the error, with nothing chopped out. Please follow these instructions to provide the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please copy the log as text and &lt;FONT color="#FF0000"&gt;paste it into the window that appears when you click on the &amp;lt;/&amp;gt; icon&lt;/FONT&gt;. &lt;STRONG&gt;DO NOT SKIP THE PART IN RED&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 15:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764708#M242233</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-08-29T15:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug Invalid Do Loop  control - Concomitant Medication Use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764765#M242249</link>
      <description>&lt;P&gt;Just for giggles, what do you think the BY ID in the Data Days data step is contributing to your code?&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 21:30:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764765#M242249</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-29T21:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug Invalid Do Loop  control - Concomitant Medication Use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764770#M242251</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;The BY ID will do 2 things: 1) slow down the code 2) verify that the data is sorted (but this information &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/create-a-VALIDATESORT-data-set-option-to-validate-the-sort-order/idi-p/288038" target="_self"&gt;is not saved&lt;/A&gt;).&lt;/P&gt;</description>
      <pubDate>Sun, 29 Aug 2021 23:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764770#M242251</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-08-29T23:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug Invalid Do Loop  control - Concomitant Medication Use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764779#M242252</link>
      <description>&lt;P&gt;The error message is very clear. You have missing values. The LOG should show you the missing values.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;19    data have;
20      input ID  DRUG $  START_DT :mmddyy. DAYS_SUPP END_DT :mmddyy.;
21      format start_dt end_dt yymmdd10.;
22    datalines;

NOTE: Invalid data for START_DT in line 24 5-11.
RULE:       ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
24          1 B 5/60/09 30  6/5/09
ID=1 DRUG=B START_DT=. DAYS_SUPP=30 END_DT=2009-06-05 _ERROR_=1 _N_=2
NOTE: The data set WORK.HAVE has 2 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


22  !           ;
25    ;
26
27    data days;
28      set have;
29      dum = 1;
30      do day = start_dt to end_dt;
31        output;
32      end;
33      format day yymmdd10.;
34    run;

ERROR: Invalid DO loop control information, either the INITIAL or TO expression is missing or the BY expression is missing, zero, or
       invalid.
ID=1 DRUG=B START_DT=. DAYS_SUPP=30 END_DT=2009-06-05 dum=1 day=. _ERROR_=1 _N_=2
&lt;/PRE&gt;
&lt;P&gt;You can trap those cases and not execute the DO loop when there are missing values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if n(start_dt,end_dt)=2 then do day = start_dt to end_dt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Aug 2021 01:31:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764779#M242252</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-08-30T01:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug Invalid Do Loop  control - Concomitant Medication Use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764881#M242266</link>
      <description>Thank you so much! There are several patients in my analyses who had not received any medication who were causing the error. This code executed perfectly.</description>
      <pubDate>Mon, 30 Aug 2021 15:29:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764881#M242266</guid>
      <dc:creator>macro_2349</dc:creator>
      <dc:date>2021-08-30T15:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug Invalid Do Loop  control - Concomitant Medication Use</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764882#M242267</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&lt;BR /&gt;You are correct. This is redundant given that the next step in my program is a PROC sort. Thank for making this much more efficient for me!</description>
      <pubDate>Mon, 30 Aug 2021 15:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-debug-Invalid-Do-Loop-control-Concomitant-Medication-Use/m-p/764882#M242267</guid>
      <dc:creator>macro_2349</dc:creator>
      <dc:date>2021-08-30T15:31:29Z</dc:date>
    </item>
  </channel>
</rss>

