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

I would like to replace the formats of a data set by some standard formats based on the type of format. That is, I would like to specify a specific format for the following categories of variables: 

  • numeric (excl. date / datetime)
  • character
  • date
  • datetime

It is straightforward to determine using code whether a variable is character or numeric. For example, using PROC CONTENTS, the information in SASHELP.VCOLUMN or the variable info functions (vtype, vtypex).

 

Is there also a way to determine the category of the format of the variable (date, datetime, etc.) using the format that is applied? Similar to the categories as described in the SAS programming documentation: Formats by category.

Information about the format is available in the three sources mentioned above, but I would like to avoid having to create the list of valid date and datetime formats myself.

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @NicoM,


@NicoM wrote:

Is there also a way to determine the category of the format of the variable (date, datetime, etc.) using the format that is applied?


Yes, there is: the FMTINFO function, as Tom illustrated last week in https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727124.

View solution in original post

3 REPLIES 3
FreelanceReinh
Jade | Level 19

Hello @NicoM,


@NicoM wrote:

Is there also a way to determine the category of the format of the variable (date, datetime, etc.) using the format that is applied?


Yes, there is: the FMTINFO function, as Tom illustrated last week in https://communities.sas.com/t5/SAS-Programming/Identify-List-all-date-fields/m-p/727124.

NicoM
Obsidian | Level 7

Thanks, @FreelanceReinh! That is exactly what I need.

 

I searched using keywords "format" and "category", but I did not come across that thread.  

FreelanceReinh
Jade | Level 19

@NicoM wrote:

I searched using keywords "format" and "category", but I did not come across that thread.  


I was just lucky that I remembered the discussion, so I could restrict my search to posts by user Tom, date: "A month ago." 🙂

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 442 views
  • 4 likes
  • 2 in conversation