DATA Step, Macro, Functions and more

Help w/ First Day of SAS Week

Not applicable
Posts: 1

Help w/ First Day of SAS Week

I've got a collection of dates of the form 20xx-wk where wk is a week number produced by the SAS week function week( ,'u').  What I'd like to do is convert my list to ordinary SAS dates corresponding to the first date of the week.  That is, let f be a function such that f(20xx,wk) = 'nnMON20xx'd where nnMON is the first date of SAS week 20xx-wk.

Have hunted around in the date function doc and don't see an obvious way to do this.  Would like to solve my problem w/o stepping out of proc SQL if possible.

Thanks in advance.

Super User
Posts: 23,754

Re: Help w/ First Day of SAS Week

1. Look up the intnx function. 

If SAS week starts on the Jan 1 of your 20XX then use week as your interval with the wk as the number of increments and 'start' as the alignment.

Respected Advisor
Posts: 3,852

Re: Help w/ First Day of SAS Week

I think the WEEKU informat is what you need.  You will need to change the - to W.

data _null_;
length x $20;
x = cats(year(today()),'W',put(week(today(),'u'),z2.));
   y = input(x,weeku.);
   put x= y=date9.;
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation