DATA Step, Macro, Functions and more

Proc format error

Frequent Contributor
Frequent Contributor
Posts: 82

Proc format error



I tried to use the followng format and put function to revalue yr_qt variable, however the first row of the format could not show off  ("2011_Q1"='1.2011_Q1' ). After put function, the 2011_Q1 is still 2011_Q1 instead of  1.2011_Q1 .


I am wondering what is wrong.  Thank you very much.


proc format ;
$yr_qtf 30.
'All years'='0.ALL years'


data table2;

set table2;

yr_qt_1 = put ( yr_qt, yr_qtf. ) ;





Trusted Advisor
Posts: 1,147

Re: Proc format error

Please remove 30. from the proc format step and the format will work.

Please let me know if it does not work.
Frequent Contributor
Frequent Contributor
Posts: 82

Re: Proc format error

Posted in reply to Jagadishkatam
Thank you very much, it works !
Super User
Posts: 23,778

Re: Proc format error

Instead of this, you may want create a custom format to display the date in that format rather than add the 1. etc I'm assuming it's to order the data, but it looks uglier in my opinion in this format. In fact, it should sort naturally, so I'm not sure why you're doing this at all...


Look into proc picture and how to create a custom date format. 


You can also look into a multilabel format to create multiple levels when formatting. 


Formats are extremely powerful, they're worth learning well. 


To diagnose your problem with your format for example you can use the following to see how proc format stored the format and noticed that the first one was missing so you could check your code.


proc format cntlout=check_format;

proc print data=check_format;



Ask a Question
Discussion stats
  • 3 replies
  • 1 like
  • 3 in conversation