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
Onyx | Level 15
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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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