BookmarkSubscribeRSS Feed
ubshams
Quartz | Level 8

I was able to import data from Excel to SAS and it's now in this format:

 

Quarter   Variable1 Variabl2

201201      1               2

201202     1                2

201203     4                1

201204     5                1

....

....

201804      5                 8

 

They are all in number format (even the Quarter column values). How do I convert the quarter column's values to a Quarterly date

format? 

 

The final goal is to get the seasonal factors but need to set the dates correctly first.

Thanks in advance!

  

 

3 REPLIES 3
Reeza
Super User
So 201201 and 201202 are 2012Q01 and 2012Q2?
ubshams
Quartz | Level 8

Yes.

Reeza
Super User

Here's one method to convert it to a SAS date.

 

data have;
quarter = 201201;output;
quarter = 201202;output;
quarter = 201203;output;
quarter = 201204;output;
run;

data want;
set have;
qtr_char = catx('Q', substrn(quarter, 1, 4), substrn(quarter, 6, 1));
date = input(qtr_char, yyq6.);
format date yyqd6.;
run;