Correct Syntax of & Complete List of Number/Date Formats Available

Accepted Solution Solved
Reply
Contributor
Posts: 51
Accepted Solution

Correct Syntax of & Complete List of Number/Date Formats Available

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.


Accepted Solutions
Solution
‎09-15-2013 03:06 PM
Respected Advisor
Posts: 3,124

Re: Correct Syntax of & Complete List of Number/Date Formats Available

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


All Replies
Solution
‎09-15-2013 03:06 PM
Respected Advisor
Posts: 3,124

Re: Correct Syntax of & Complete List of Number/Date Formats Available

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

Contributor
Posts: 51

Re: Correct Syntax of & Complete List of Number/Date Formats Available

Fabulous reference for sure buddy!
Thanx again!

Super Contributor
Posts: 339

Re: Correct Syntax of & Complete List of Number/Date Formats Available

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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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