BookmarkSubscribeRSS Feed
hellind
Quartz | Level 8

The dataset is WORK.HOLIDAYS

It looks like this:

HOLIDAY

1/1/2014

31/1/2014

14/2/2014

How do I load this dataset into any array?

6 REPLIES 6
LinusH
Tourmaline | Level 20

This is basic SAS programming, and you'll find your answer in the documentation or in training material.

Question is, what is the requirement for your question?

Data never sleeps
Tom
Super User Tom
Super User

Despite the title on your post it looks like you already have the data in a data set.  What do you mean by wanting to create an array? If you explain the larger picture of what you are trying to do then someone might be able suggest a method.

hellind
Quartz | Level 8

THanks for the help. After spending some time, this is what I ended up with and it works.

PROC SQL;

     SELECT CAT("'", PUT(HOLIDATE,DATE9.),"'D") INTO  :HOLIDAYLIST SEPARATED BY ',' FROM SMLS.HOLIDAYS

;QUIT;

DATA SMLS.CA1;

SET SMLS.CA;

     HOLIDAY = 0;

DO HOLIDATE = &HOLIDAYLIST;

IF DATEPART(LAST_UPDATE_DATE) < HOLIDATE AND DATEPART(FIRST_UPDATE_DATE) > HOLIDATE THEN HOLIDAY = HOLIDAY + 1;

END;

IF HOLIDAY >=1 THEN SLA = SLA - (24*HOLIDAY);

OUTPUT;

DROP HOLIDATE

RUN;

hellind
Quartz | Level 8

Basically counting the number of public holidays between the start date and end date.

Reeza
Super User

That isn't an array, that's a macro variable list.

Arrays in SAS operate differently than other languages, so its worth reading the documentation.

Tom
Super User Tom
Super User

No need for macro variables to do that logic.  You can read directly from the source table by using POINT= option on SET statement.

DATA SMLS.CA1;

  SET SMLS.CA;

  HOLIDAY = 0;

  DO p=1 to nobs ;

    SET SMLS.HOLIDAYS(keep=HOLIDATE) point=p nobs=nobs ;

    IF DATEPART(LAST_UPDATE_DATE) < HOLIDATE AND DATEPART(FIRST_UPDATE_DATE) > HOLIDATE

       THEN HOLIDAY = HOLIDAY + 1

    ;

  END;

  IF HOLIDAY >=1 THEN SLA = SLA - (24*HOLIDAY);

  DROP HOLIDATE

RUN;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 2389 views
  • 4 likes
  • 4 in conversation