DATA Step, Macro, Functions and more

Mixing of implicit and explicit array subscripting error message

Reply
Frequent Contributor
Posts: 138

Mixing of implicit and explicit array subscripting error message

Hi everyone,

I have an employee database at the person level where each row is a person and a set of start/end dates. These dates represent the dates at which participants began and ended various work programs, eg:

Participant      Start Date 1     Start Date 2...Start Date 16     End Date 1     End Date 2...End Date 16

A                    1/1/2009          2/3/2009        4/6/2012           10/1/2010        3/5/2009       4/7/2013

The start and end dates are paired (that is, Start Date 1 corresponds with End Date 1), but the date periods are independent and can overlap (Start Date 2 can be between Start Date 1 and End Date 1.

I am trying to evaluate how many participants were enrolled in any program on January 1, 2012. That is, for how many people are there a start/end date pair for which January 1, 2012 is in the middle, or for which January 1, 2012 is the start date.

Here's the code I'm trying to use:

data data;

set data;

array start(i) startdate1-startdate16;

array end(i) enddate1-enddate16;

prog_enrol=0;

do i=1 to 16;

if start(i)<='01JAN2012'd<=end(i)

then prog_enrol=1;

end;

When I do this, I get an error message saying this:

ERROR: Mixing of implicit and explicit array subscripting is not allowed.

Any help is much appreciated.

Respected Advisor
Posts: 3,777

Re: Mixing of implicit and explicit array subscripting error message

Change these statements

array start(i) startdate1-startdate16;

array end(i) enddate1-enddate16;

to

array start startdate1-startdate16;

array end enddate1-enddate16;

Which is somewhat ambiguous

or to be explicit

   array start

  • startdate1-startdate16;
  •    array end

  •    enddate1-enddate16;
  • Respected Advisor
    Posts: 4,646

    Re: Mixing of implicit and explicit array subscripting error message

    The syntax problem is with the ( i ) subscripts in array statements. You can count participants in programs on a given target date using:

    data have;

    input Participant $     StartDate1     StartDate2 StartDate3     EndDate1     EndDate2 EndDate3;

    informat startDate: endDate: mmddyy10.;

    format startDate: endDate: yymmdd10.;

    datalines;

    A                    1/1/2009          2/3/2009        4/6/2012           10/1/2010        3/5/2009       4/7/2013

    B                    1/2/2009          2/4/2009        4/7/2012           10/2/2012        3/6/2012       4/8/2013

    ;

    proc print data=have; var startDate1 endDate1 startDate2 endDate2 startDate3 endDate3; run;

    data haveLong(keep=Participant program startDate endDate);

    set have;

    array sd{*} startDate:;

    array ed{*} endDate:;

    do program = 1 to dim(sd);

      startDate = sd{program};

      endDate = ed{program};

      output;

      end;

    run;

    %let targetDate=15JUL2012;

    proc sql;

    create table want as

    select program, count(*) as participantsInProgram

    from haveLong

    where "&targetDate"d between startDate and endDate

    group by program;

    select * from want;

    quit;

    PG

    PG
    Ask a Question
    Discussion stats
    • 2 replies
    • 1668 views
    • 0 likes
    • 3 in conversation