BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
FarazA_Qureshi
Calcite | Level 5

Hi friends!

This newbie sure is anxious to know how to find out and apply the correct format available for Date(s)/Numbers. Sure would appreciate if any of you experts could help by referring some rich source of info in this regard to find ALL the options available and way to use the same.

For instance how to apply date formats in PROC SQL like:

Select DOB, UserName from Work.TempTable

where DOB represents the Date of Birth desired to be returned in the format MMMM DD, YYYY i.e. with full month's name and days in two digits like August 08, 1976.

Thanx in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

What you would be needing is worddate. format,

data have;

DOB='08aug1976'd;

run;

proc sql;

select DOB format=worddate20. from have;quit;

Here is the link for all the SAS 9.3 format:

SAS(R) 9.3 Formats and Informats: Reference

HTH,

Haikuo

View solution in original post

3 REPLIES 3
Haikuo
Onyx | Level 15

What you would be needing is worddate. format,

data have;

DOB='08aug1976'd;

run;

proc sql;

select DOB format=worddate20. from have;quit;

Here is the link for all the SAS 9.3 format:

SAS(R) 9.3 Formats and Informats: Reference

HTH,

Haikuo

FarazA_Qureshi
Calcite | Level 5

Fabulous reference for sure buddy!
Thanx again!

Vince28_Statcan
Quartz | Level 8

A book I have found useful is

The essential guide to SAS Dates and Times

Art Carpenter's SAS software series by Derek P. Morgan

It does not, however, cover many other numeric formats like hex, binary, etc. as you can see by the books' name.

The date format you are looking for to output full month day, year could be built with a picture statement in proc format or with the existing WORDDATEw. format. It's backdraw is that it adds leading blanks to shorter month names.

WORDDATE18. is the minimum  width to get full month name parsed, with necessary leading blanks for all but september. Anything below 18 will cut to 3letter abbreviation. Anything beyond 18 will add however much more leading blanks.

I'm not sure of any detailed way to gather information on all format from within SAS (like one you could query and do manipulation to document another dataset with). There's always sashelp.vformat but there are no description of the formats so it is not the most useful dictionary table.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 493 views
  • 0 likes
  • 3 in conversation