BookmarkSubscribeRSS Feed
P_S_
Obsidian | Level 7

Hello,

I am trying to create a list of variables in my dataset and separte them in 3 categories.
CHARACTER, NUMERIC and DATE.

I am using dictionary.columns to get the variables. I can easily get the character and numeric but the problem with numeric is that the date variable is also of type numeric and I want them separated.
Is there an easy way to separate date variables from numeric?

BTW i tried to make use of format as well but as you know there could be any kind of date format. I am hoping there is an easy and clever way of doing this.

Any help is appreciated.

Thank you,

P.S.

7 REPLIES 7
LinusH
Tourmaline | Level 20

As you already concluded, there is no specific data type for dates in SAS.

So, there is no bullet proof way.

You could, as you mentioned, try to look at different attributes, and then guess if it's a date column. Format is one, naming another. You could also look at the contents in the columns to see if they have normal data values (10s of thousands).

I don't know anything about your application, but when building systems/databases, naming conventions are crucial so users can easily understand the contents of tables and columns.

Data never sleeps
Peter_C
Rhodochrosite | Level 12

might the FORMAT column in the dictionary.columns help?

jakarman
Barite | Level 11

Why not use a metadatabase appoach  DI/Bi is having that. It is the role of the metadataserver and the DI basics to do this.

---->-- ja karman --<-----
Patrick
Opal | Level 21

@Jaap

I'm not aware of table metadata definition having a specific column attribute for dates. Can you please elaborate what you're proposing here?

Peter_C
Rhodochrosite | Level 12

SAS9.4 allows us to add extended variable and table attributes.

See PROC DATASETS Example 12 Extended Attributes at http://support.sas.com/documentation/cdl/en/proc/64787/HTML/default/n1fi5duus5pm9xn1csr0vzaccytt.htm

jakarman
Barite | Level 11

When you are using Eguide is will be a client/server approach.

The Server can be your local desktop but a lot of power will come from servers and the most proposed ones are Unix based (Linux redhat suse and Aix). You can recognize that if you need to define a profile to reach a server.  Workspace Servers are just  one type of objects that can be defined. 

SAS libraries and data elements can also be defined and redefined. That redefining can be done witht Information map studio.

That manual is showing some of what is done. 

SAS(R) Information Map Studio 4.2: Getting Started with SAS(R) Information Maps (Creating Data Items) is showing dates being defned as types. They are still numeric as it is normal SAS on the backgound there.

Going into details you can add descriptions to elements. In DI is something found for it.

SAS(R) Data Integration Studio 4.7: User's Guide (Add a Note or Document to a Registered Object)

It are the tools for modeling describing the data. There are interfaces to other tools doing this in the same way .

With these descritpions new code can be generated. Not coding by hand but defining relationships with transformations.

By that the metdatabase will become something containing information in a similar way as you would do change-management to source-code.

The fun of this approach is that when it is complete you can easily have and use tools for analysing impacts in those relations and logic.    

SAS(R) Data Integration Studio 4.7: User's Guide (impact analysis)

---->-- ja karman --<-----
data_null__
Jade | Level 19

In future XATTR could be used to added the DATE attribute when the data set is defined.

As mentioned the format should help and there aren't so many that you can't figure it out.

When you get it figured make the INFORMAT for the DATE variables DATE9.  Unless you have v9.4 and can use XATTR.

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
  • 7 replies
  • 1168 views
  • 5 likes
  • 6 in conversation