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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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