Proc format

Reply
N/A
Posts: 0

Proc format

I need to format dates. for eg;
proc format;
value dates;
'1'=day0+ -3
'2'=day 2 + - 7
so on..
How can return a complete value like
day0+ - 3 should give me 09/03/07 in the result.
Also is there a way to insert the +- symbol instead of typing + and _ seperately.

Thanks,
Aps
SAS Super FREQ
Posts: 8,721

Re: Proc format

Hi:
I am confused by your format and what it is that you want to do. SAS dates represent the number of days that have elapsed since Jan 1, 1960 -- which is the date stored as the number 0 in SAS. So, for example the following 3 dates are stored as the numbers shown next to them:
[pre]
date date stored as number
------------ ------------------------
Jan 1, 1959 -365
Jan 1, 1960 0
Dec 31, 1961 730
[/pre]

Therefore, the date Jan 2, 1960 would be internally stored as the number 1; and the date Jan 3, 1960 as the number 2, etc, etc.

Then, you could FORMAT the internally stored number with one of the date formats supplied by SAS or with a picture format that you designed yourself. So, for example, the table below shows how each format would be used to display the internal number (with some other numbers added):
[pre]
date stored
as number date9. mmddyy10.
--------------- ---------- ----------
-3334 15NOV1950 11/15/1950
-365 01JAN1959 01/01/1959
0 01JAN1960 01/01/1960
730 31DEC1961 12/31/1961
2495 31OCT1966 10/31/1966

[/pre]

However, using a FORMAT does not change the internally stored number. It only changes how the number LOOKS on reports and graphs.

It seems as though the variable you are trying to format might not be a SAS date value -- since the number 1 as a SAS date value would represent Jan 2, 1960 -- NOT 09/03/2007. In addition, you have a character value on the left hand side of the = sign in the format, which would normally mean that you were designing a character format. However, your VALUE statement shows a name for a numeric format.

You might consider contacting Tech Support for help with your question. They can review your program code and your data and help you achieve your desired results. To find out how to contact Tech Support, refer to this site:
http://support.sas.com/techsup/contact/index.html

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 304 views
  • 0 likes
  • 2 in conversation