Hi
I want to convert values in period column to quarter end date as in the date column. Please provide the solution.
Period datatype: character
Period Date
Q12022 31.03.2022
Q22022 31.06.2022
Q32022 30.09.2022
Q42022 31.12.2022
Q12023 31.03.2023
data have;
input quarterC : $ 6. date ddmmyy10.;
format date ddmmyy10.;
cards;
Q12022 31.03.2022
Q22022 30.06.2022
Q32022 30.09.2022
Q42022 31.12.2022
Q12021 31.03.2023
;
run;
data want;
set have;
quarterDT = input(substr(quarterC,3,4) !! substr(quarterC,1,2), yyq6.);
format quarterDT date11.;
run;
proc print;
run;
data qtr (drop=temp);
input Period $;
temp=input(trim(left(substr(period,3)))||left(substr(period,1,2)),yyq6.);
newdt2=intnx('qtr',temp,0,'end');
format newdt2 ddmmyy10.;
cards;
Q12022
Q22022
Q32022
Q42022
Q12023
;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.