Create SAS Date informat

New Contributor
Posts: 3

Create SAS Date informat

Hi Community

I am working with an excel dataset, where the 'obs' column consists of dates of the form 'yyyy:q' eg. 1991:1.

This date is loaded into my SAS program as a character variable. So my problem is how to convert this 'obs-column' of character data

into an 'obs-column' of SAS dates(numeric data).

I have tried using the input('var1', informat) solution to convert character data into numeric data, but I do not have the 'yyyy:q' informat in my SAS 9.4 software.

So a related problem is how to create a date informat of the type 'yyyy:q'.



Super User
Super User
Posts: 9,599

Re: Create SAS Date informat

Posted in reply to JasonSeff

There are year/quarter formats:

Maybe just do:


New Contributor
Posts: 3

Re: Create SAS Date informat

Thank you for the answer.

I have searched extensively for answers in the format/informat documentation, but haven't found any solutions to my problem.

I tried running the following code using your suggestion(slightly modified), and, barring coding errors, I can't get the desired result.

yyqxc. is the format I want 'yyyy:q' is the informat I need, to read the character variable I labeled obs in the column below.

SAS does not have the required INformat to read the variable. Neither the yyqs8. nor yyqc. which is the INformat I need. 

data have;

    input obs $ y;



1991:3 11

1991:4 22

1992:1 33



Respected Advisor
Posts: 3,852

Re: Create SAS Date informat

I did not find an INFORMAT called YYQS.  I did get this to work.

84   data _null_;
85      x = '2015:2';
86      d = input(translate(x,'q',':'),yyq6.);
87      format d yyqc.;
88      put _all_;
89      run;

x=2015:2 d=2015:2 _ERROR_=0 _N_=1
New Contributor
Posts: 3

Re: Create SAS Date informat

Posted in reply to data_null__

Thank you for the answer.

Not the type of solution I was expecting, but I played around with it a bit and customized the solution to my data set, and it did the job.

Allthough I didn't get any closer to creating my 'yyyy:q' informat, both of your suggestions led to a clever and workable solution to my problem.


Ask a Question
Discussion stats
  • 4 replies
  • 3 in conversation