Skip to content

Instantly share code, notes, and snippets.

@rudvfaden
Created May 28, 2021 06:49
Show Gist options
  • Save rudvfaden/ed9f06ec3e97f753b8d366bbaa6a04b9 to your computer and use it in GitHub Desktop.
Save rudvfaden/ed9f06ec3e97f753b8d366bbaa6a04b9 to your computer and use it in GitHub Desktop.
Calculates Danish hollidays
%let _output=DimHelligdag;
proc datasets lib=DM_FL_HR nolist;
delete &_output;
run;
data &_output;
StartDato=intnx('year',today(),-6,'B');
Slutdato=intnx('year',today(),3,'E');
attrib &_OUTPUT1_col1_name length=&_OUTPUT1_col1_type&_OUTPUT1_col1_length;
do dato=StartDato to Slutdato;
aar = year(Dato);
a = mod(aar,19);
b = int(aar/100);
c = mod(aar,100);
d = int(b/4);
e = mod(b,4);
f = int((b+8)/25);
g = int((b-f+1)/3);
h = mod((19*a+b-d-g+15),30);
i = int(c/4);
k = mod(c,4);
l = mod((32+2*e+2*i-h-k),7);
m = int((a+11*h+22*l)/451);
n = int((h+l-7*m+114)/31);
p = mod((h+l-7*m+114),31);
paaske = mdy(n,p+1,aar);
if Dato = paaske-3 then do;
Helligdag = "Skærtorsdag";
output;
end;
if Dato = paaske-2 then do;
Helligdag = "Langfredag";
output;
end;
if Dato = paaske+1 then do;
Helligdag = "2.Påskedag";
output;
end;
if Dato = paaske then do;
Helligdag = "Påskedag";
output;
end;
if Dato = paaske+26 then do;
Helligdag = "Store bededag";
output;
end;
if Dato = paaske+39 then do;
Helligdag = "Kr. himmelfart";
output;
end;
if Dato = paaske+49 then do;
Helligdag = "pinsedag";
output;
end;
if Dato = paaske+50 then do;
Helligdag = "2. pinsedag";
output;
end;
if Dato = mdy(12,24,aar) then do;
Helligdag = "Juleaftensdag";
output;
end;
if Dato = mdy(12,25,aar) then do;
Helligdag = "Juledag";
output;
end;
if Dato = mdy(12,26,aar) then do;
Helligdag = "2. juledag";
output;
end;
if Dato = mdy(01,01,aar) then do;
Helligdag = "Nytårsdag";
output;
end;
if dato = mdy(05,01,aar) then do;
Helligdag = "1. maj";
output;
end;
if dato = mdy(06,05,aar) then do;
Helligdag = "Grundlovsdag";
output;
end;
end;
keep dato helligdag;
format dato date9.;
run;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment