I have a list of 10k + records that contain a 10 digit item number. And an effective date and a term date for each.
Effectively taking an unbroken date span and make a record for each month effective. I have a date span table created
but have no idea as to how to change the span to per month records. Please see the input output example below. Thank you in advance.
Example:
Input
ITEM EFFDATE TRMDATE
0123456789 01JAN2018 31JUN2018
Desired Output :
ITEM EFFMTH COUNT
0123456789 012018 1
0123456789 022018 1
0123456789 032018 1
0123456789 042018 1
0123456789 052018 1
0123456789 062018 1
0123456789 072018 0
0123456789 082018 0
0123456789 092018 0
0123456789 102018 0
0123456789 112018 0
1. Use INTCK to determine number of intervals
2. Use INTNX to calculate new date variable.
3. Use a LOOP with OUTPUT to explicitly write out new records.
data want;
set have;
n_intervals = intck('month', effdate, trmdate);
do i=0 to n_intervals
Date = intnx(month, effDate, i, 'b');
format date yymmn6.;
OUTPUT;
end;
run;
@PotTheCat wrote:
I have a list of 10k + records that contain a 10 digit item number. And an effective date and a term date for each.
Effectively taking an unbroken date span and make a record for each month effective. I have a date span table created
but have no idea as to how to change the span to per month records. Please see the input output example below. Thank you in advance.
Example:
Input
ITEM EFFDATE TRMDATE
0123456789 01JAN2018 31JUN2018
Desired Output :
ITEM EFFMTH COUNT
0123456789 012018 1
0123456789 022018 1
0123456789 032018 1
0123456789 042018 1
0123456789 052018 1
0123456789 062018 1
0123456789 072018 0
0123456789 082018 0
0123456789 092018 0
0123456789 102018 0
0123456789 112018 0
data want;
set have;
do while(EFFDATE<TRMDATE);
output;
EFFDATE=intnx('month',EFFDATE,1);
if EFFDATE>TRMDATE then leave;
end;
/*format EFFDATE however you want;*/
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: