BookmarkSubscribeRSS Feed
jackw19
Calcite | Level 5

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.

2 REPLIES 2
Reeza
Super User

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.

data_null__
Jade | Level 19

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.;
  
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 773 views
  • 0 likes
  • 3 in conversation