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?
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?
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.
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;
Basically counting the number of public holidays between the start date and end date.
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.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.