Hi all,
Scenario 1:
I have only 2 years (2015, 2016) with start and end dates in data set.
|
Start |
End |
|
201511 |
201610 |
Now based on above data set is basically range with 2 date (start & End) need to split according to year & month as shown in below table:
S: start date
E: Ending date of that year
S1: continuity of year start
E1: Ending of study date.
|
Start |
End |
S |
E |
S1 |
E1 |
|
201511 |
201610 |
201511 |
201512 |
201601 |
201610 |
Scenario 2:
I have only 3 years (2015, 2016, and 2017) with start and end dates in data set.
|
Start |
End |
|
201511 |
201703 |
Now based on above data set is basically range with 2 date (start & End) need to split according to year & month as shown in below data set table:
S: start date
E: Ending date of that year
S1: continuity of year start
E1: Ending date of that year
S2: continuity of year start
E2: Ending of study date.
|
Start |
End |
S |
E |
S1 |
E1 |
S2 |
E2 |
|
201511 |
201610 |
201511 |
201512 |
201601 |
201612 |
201701 |
201703 |
How to create this data set?
Thanks,
Ganesh K
Well, this will give you an idea of how to do it. I couldn't figure out your ending dates logic? Also, I would as always recommend that having a long structure rather than a wide structure will make oyur coding far easier.
data have;
start=input("201511",yymmn6.);
end=input("201610",yymmn6.);
run;
data want;
set have;
array s{3} 8;
array e{3} 8;
s{1}=start;
e{1}=end;
do i=2 to (year(end)-year(start))+1;
s{i}=intnx('year',start,i-1,'b');
end;
format s: e: yymmn6.;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.