BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lamiaH
Obsidian | Level 7

Hi everyone, 

 

I had date variables of a certain test. You've helped me before in converting this to only month-year variable by using yymon7., but after lookign at the counts, it turned I need to convert it to a quarterly date to make the counts larger, to do a time series analysis later. I need the date to be instead of jan2016, Feb2016 with their counts to be Quarterly. 

 

I have many questions:

Q1. I've tried proc expand to convert the time from month to QTR and it didn't work. 

proc expand data=monthly out =quarterly. 

from =month to =QTR;

convert feecode;

id date;

run;

 

Also tried q_date= QTR(date) and it just gave me number 1, 3....

Q2) I need to make time slices at certain intervention dates for a time series analysis, any one has a useful codes for these? I know it is complicated. If just a link for a useful coding source. 

 

Thank you so much, 

Lamia

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Formats such as YYQ6.  show date value as 2017Q1, yyQx allows you to specify character such as - / . <blank> or : between year and quarter number, YYQR displays the quarter as a Roman numeral yyqr7. would show 2017QI through 2017QIV, and the YYQRX uses the roman numeral plus a specified character as the yyqx does.

 

Or roll your own with Proc Format.

View solution in original post

2 REPLIES 2
Reeza
Super User

Look at the formats available and I'm 99% sure there's a year quarter one. Use that instead.

https://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#n0p2fmevfgj...

 

This page has the formats by category, so in the Date/DateTime section, find one that does what you want.

ballardw
Super User

Formats such as YYQ6.  show date value as 2017Q1, yyQx allows you to specify character such as - / . <blank> or : between year and quarter number, YYQR displays the quarter as a Roman numeral yyqr7. would show 2017QI through 2017QIV, and the YYQRX uses the roman numeral plus a specified character as the yyqx does.

 

Or roll your own with Proc Format.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6717 views
  • 2 likes
  • 3 in conversation