Converting from Month year date to quarterly dates

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

Converting from Month year date to quarterly dates

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


Accepted Solutions
Solution
‎08-30-2017 10:38 PM
Super User
Posts: 13,316

Re: Converting from Month year date to quarterly dates

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


All Replies
Super User
Posts: 23,275

Re: Converting from Month year date to quarterly dates

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.

Solution
‎08-30-2017 10:38 PM
Super User
Posts: 13,316

Re: Converting from Month year date to quarterly dates

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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