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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1967 views
  • 4 likes
  • 4 in conversation