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

Hello everyone,

 

is it possible to select from a table where variable type is date.

Exemple: table x contains several columns, some of them are date type

what i want is to select from x where the type is date.

knowing that i Don't know the variables names.

 

thank you so much

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use the FMTINFO function to figure out if the format is a date/datetime category, unfortunately it filters both dates and datetimes. 

https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=n08tazkeygnw9on138axalvpy9p4.htm...

 

 

 

View solution in original post

3 REPLIES 3
ballardw
Super User

SAS data sets have two variable types: numeric and character.

If a variable is numeric and has been assigned a date type format you might be able to find them. Or your variables have been assigned a label with the word Date as part of the label.

 

If you don't have either of those then unlikely and either of those would require searching the data set variable attributes, likely creating a macro variable and then using the macro variable in Keep data set option.

 

It may be easier to just run proc contents or examine table properties directly in the SAS Explorer to find these.

 

Unfortunately when "dates" are buried in character values or simple numeric values like 19960422 without a format they are unlikely to be found.

PeterClemmensen
Tourmaline | Level 20

So you want to select all the variables that are formated as dates, correct?

Reeza
Super User

Use the FMTINFO function to figure out if the format is a date/datetime category, unfortunately it filters both dates and datetimes. 

https://documentation.sas.com/?docsetId=lefunctionsref&docsetTarget=n08tazkeygnw9on138axalvpy9p4.htm...

 

 

 

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 315 views
  • 0 likes
  • 4 in conversation