1

does any one know how to get weeknumber within sas proc sql ?

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
iamjeannie
  • 61
  • 2
  • 5

2 Answers2

5

Personally, I find it very hard to go past SAS's own, native WEEK function. It can be called from inside proc sql. Pass it a date value and it will give you the week number.

sasfrog
  • 2,410
  • 1
  • 17
  • 28
  • 2
    More on the week function can be found in the online docs: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003154994.htm – Laurent de Walick Mar 24 '11 at 13:48
1

Found this at the following link: http://www.hollandnumerics.co.uk/sasfaq/SASFAQ1.HTM

You can simulate a WEEK function by using the SAS functions INTCK and INTNX, e.g.:

DATA getweek;
   datevar=TODAY();
   week=INTCK('WEEK',
         INTNX('YEAR',datevar,0),
         datevar)+1;
RUN;
eupton
  • 221
  • 2
  • 10