BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
1 REPLY 1
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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