BookmarkSubscribeRSS Feed
Guinaba
Fluorite | Level 6

Hi all,

Based on the data set below, I would like to have another col (Commence_Day) getting the date of first day of the week col(Week).

For example:

Week                  Commence_Day

Week31                    29/07/13

Week32                    05/08/13

Week33.                   12/08/13

   

Any suggestion?

WeekCOL1COL2COL3COL4COL5COL6COL7COL8COL9COL10COL11
Article40364036419341934193419341934193419395859585
Week3118013805285521083241081924084305480
Week3219224968168042403843841446486105810
Week3318023406966961804083121925765130600
Week3412023047328041924203481686364725360
Week3524022809367801925043842408285670720
Week361921800100812962406485882649966105660
Week374830028833684156108963721110255
2 REPLIES 2
Patrick
Opal | Level 21

The SAS calendar function intnx() will allow you to shift a week to wherever you want to. BUT: You need a SAS date value as starting point for this.

intnx('week',<sas date value>,0,'b') would give you the Sunday the week starts, intnx('week.2',<sas date value',0,'b') would give you the Monday.

The issue with your data is: You don't have a SAS date value. Your variable "Week" doesn't even say in which year this week is  - which is kind of important to come up with the correct date. So to get from your data containing a string for a week number to a date some coding will be required. The data you've provided is not sufficient to do this. We need at least the year as well.

Just as an idea:

- Create a new variable with has the year and week in it, eg. WeekYear with values like '2013Week1'

- Create a data set to be used to create an informat (look up in docu: Proc Format with cntlin). The data set would have the WeekYear values in the Start variable and the SAS date values as label.

- Apply the informat on your WeekYear variable to populate a new variable containing SAS date values as required

Guinaba
Fluorite | Level 6

Thank you Patrick!! I will follow your suggestions to correct this data set!! Much appreciate it!!!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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