Desktop productivity for business analysts and programmers

How to convert date from 2014Q3 to 30SEP2014

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 82
Accepted Solution

How to convert date from 2014Q3 to 30SEP2014

I have a date that is coming in from an excel like this:2014Q3.

How to convert this to the last day of the quarter and store in date9. format like 30SEP2014.t


Accepted Solutions
Solution
‎11-04-2014 02:14 PM
PROC Star
Posts: 7,428

Re: How to convert date from 2014Q3 to 30SEP2014

Depends upon whether it imported as a SAS date or as a character variable. Here is how to convert either:

data have;

  input qtr  yyq6.  charqtr $;

  format qtr cqtr date9.;

  qtr=intnx('quarter',qtr,0,'E');

  cqtr=intnx('quarter',input(charqtr,yyq6.),0,'E');

  cards;

2014Q3 2014Q3

;

View solution in original post


All Replies
Solution
‎11-04-2014 02:14 PM
PROC Star
Posts: 7,428

Re: How to convert date from 2014Q3 to 30SEP2014

Depends upon whether it imported as a SAS date or as a character variable. Here is how to convert either:

data have;

  input qtr  yyq6.  charqtr $;

  format qtr cqtr date9.;

  qtr=intnx('quarter',qtr,0,'E');

  cqtr=intnx('quarter',input(charqtr,yyq6.),0,'E');

  cards;

2014Q3 2014Q3

;

🔒 This topic is solved and locked.

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

Discussion stats
  • 1 reply
  • 363 views
  • 0 likes
  • 2 in conversation