Generally, to recode means to use a user-defined format. This means that the date would still be internally stored as 1 Jan 2009 (for example) but would be -displayed- on reports as 14 Jan 2009. Is this what you want? If so, then investigate user-defined formats and how to create them from a SAS dataset using the CNTLIN option.
On the other hand, if by "recode" you mean to create a new variable, then you probably don't need a user-defined format and can just use the INTNX function in a DATA step program to create your new variable
You may still need to use the INTNX function to create the user-defined format.
I'm also not sure what you mean by "the first date of the period is the value for the period" -- consider this dataset of 2 variables or columns:
[pre]
Name Start
Alan 1 Jan 2009
Bob 5 Jan 2009
Carl 10 Jan 2009
[/pre]
Do you want a NEW dataset that is a copy of the old dataset, but with the START variable -changed- so it represents the start day of the -next- period?
[pre]
Name Start
Alan 15 Jan 2009
Bob 19 Jan 2009
Carl 24 Jan 2009
[/pre]
Or, do you want the original dataset variables, plus a new variable:
[pre]
Name Start Next
Alan 1 Jan 2009 15 Jan 2009
Bob 5 Jan 2009 19 Jan 2009
Carl 10 Jan 2009 24 Jan 2009
[/pre]
Or, do you just want the original dataset to -display- the start value when you use the dataset with PROC PRINT or some other report procedure????
Another way to interpret your sentence is that if someone's date falls -within- the 2 week period, then you want their START variable to be adjusted to be the first day of the 2 week period.
[pre]
Name P_Date Start_Period
Alan 1 Jan 2009 1 Jan 2009
Bob 5 Jan 2009 1 Jan 2009
Carl 10 Jan 2009 1 Jan 2009
[/pre]
Your verbal description of how the date needs to be adjusted is certainly do-able in a couple of different ways.
However, your input data structure and your desired output (either data or report) will determine the method you use in a SAS program -- whether you use a DATA step program and the INTNX function; whether you use a DATA step program to make a user-defined format; what the output dataset looks like; or what the output report looks like.
Here's a possible scenario: You have data with customers and purchase dates. You want to summarize the amounts they spent by each 2-week (fortnightly) period. So the calculated or adjusted date needs to be used for summary and reporting purposes.
Here's another possible scenario: You have data with patients and their doctor's visits and you want some counts of how many patients' visits fell within each 2 week period.
Here's another possible scenario: You have data with customer name or patient name and some date. You need to track or check something on a date basis. So if your customer's date is 1 Jan 2009, you need to check something based on 15 Jan 2009 being the start of the period after 1 Jan 2009.
Here's another possible scenario: You need to generate a file with all the 2 week or fortnightly periods in 2009:
[pre]
Obs firstday lastday
1 01JAN2009 14JAN2009
2 15JAN2009 28JAN2009
3 29JAN2009 11FEB2009
4 12FEB2009 25FEB2009
5 26FEB2009 11MAR2009
6 12MAR2009 25MAR2009
. . . more . . .
[/pre]
Having some idea of what the input data looks like and what you need to do (the big picture), will help provide the context for the kind of program you need to write. You've provided one piece of the puzzle:
date + 13 = end of period
date + 14 = start of next period
cynthia