BookmarkSubscribeRSS Feed
hasnasherin
Calcite | Level 5

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

2 REPLIES 2
yabwon
Amethyst | Level 16
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;
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



jebjur
SAS Employee

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;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1131 views
  • 2 likes
  • 3 in conversation