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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.