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;
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 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.