SAS Community Nordic

Nordic SAS users community Interact, learn and grow for all SAS Problem Solvers
BookmarkSubscribeRSS Feed
jmic_nyk
Obsidian | Level 7

I often have problems with converting the result of the weekday function which gives you sunday as first day of week. However in our part of the world we use monday as first day of week. 

 

Here is a function that kan do just that - convert:

 

proc fcmp outlib = work.funktion.dk_ugedag;
function dk_ugedag(_sasdato);
return(weekday(_sasdato)-1+(weekday(_sasdato)=1)*7);
endsub;
run;

 

 

2 REPLIES 2
GertNissen
Barite | Level 11

Hej Jesper

 

Tak for dit indlæg og for at dele Tips & Tricks - Godt eksempel på anvendelse af PROC FCMP du der giver.

 

En anden mulighed er at benytte NLS funktionerne (National Language Support) til at både at returne korrekt ugedag (nr 3) med dansk tekst. 

 

Obs dato dk_ugedag
1 21369 onsdag

 

Test selv med denne kode

options locale=Danish_Denmark;

data ugedag;
  dato=today();
  dk_ugedag = NLDATE(dato,'%A');
run;

Link til NLDATE dokumentationen, hvor der også er diverse eksempler
http://go.documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=nlsref&docsetTarget=n14463n...

 

Bemærk f.eks. forskellen mellem %u og %w

jmic_nyk
Obsidian | Level 7

Ja - hvorfor skulle jeg være den eneste med det problem. SAS har selvfølgelig allerede løst det. Og %u giver endda lige præcis det jeg har brug for.

 

Takker.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Discussion stats
  • 2 replies
  • 1538 views
  • 5 likes
  • 2 in conversation