BookmarkSubscribeRSS Feed
Walternate
Obsidian | Level 7

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.

2 REPLIES 2
data_null__
Jade | Level 19

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;
  • PGStats
    Opal | Level 21

    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

    sas-innovate-white.png

    Special offer for SAS Communities members

    Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

     

    View the full agenda.

    Register now!

    How to Concatenate Values

    Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

    Find more tutorials on the SAS Users YouTube channel.

    SAS Training: Just a Click Away

     Ready to level-up your skills? Choose your own adventure.

    Browse our catalog!

    Discussion stats
    • 2 replies
    • 7431 views
    • 0 likes
    • 3 in conversation