BookmarkSubscribeRSS Feed
Calcite | Level 5

I have Sas va 7.4
When I import a database, it defaults placing the time field as a category and not as a metric. How do I change this while maintainin

my hourly format?


An example of what I am trying to produce:



Thank you.

Lapis Lazuli | Level 10

what makes you say sas is treating it as a categorical variable? does it appear as a character variable? is sas throwing an error when you use eg proc univariate?

Opal | Level 21

Check your data source. Is the time field defined as character? That would explain why VA is treating it as a category.


How are you importing from the database and what is the database? The best solution is to get the import working correctly so the time field is defined as a numeric with a SAS time format.

Calcite | Level 5



My import process is pretty simple. I created an example for you to see. I created 2 columns database with "Enter" column that is defined as time (you can see in the picture). Next, I export it to LocalData Folder as SAS file (sas7bdat). Then, i imported it to VA.


VA sees it as an hour as it should but im unable to change is to measure.

Please see attached pictures.



Opal | Level 21

OK, it appears date and time fields are treated as type category and you can't change this. However you can derive measures from these as explained in this post:

Calcite | Level 5



i copied the solution from the post you gave me (I took from the last replay)


IF ( Sum [_ByGroup_] ('timeSec'n) <= 3600 )

RETURN ( Floor(( Sum [_ByGroup_] ('timeSec'n) / 60 )) + ( ( Sum [_ByGroup_] ('timeSec'n) Mod 60 ) / 100 ) )

ELSE ( ( Floor(( Sum [_ByGroup_] ('timeSec'n) / 60 )) + ( ( Sum [_ByGroup_] ('timeSec'n) Mod 60 ) / 100 ) ) / 60 )



This solution isn't good enough because in some cases the minutes are over 60 as you can see in the picture bellow



Opal | Level 21

What happens if you format the calculated measure as hours, minutes, seconds?

Calcite | Level 5

It's going back to category.


No matter what I do, if I'm using time format in a calculation its going back to category.


I got an answer from SAS that it's impossible to use time (in time format) as a measure in VA 7.4


8.2 Version is more flexible and it can be done. Bottom line, I need to upgrade my VA.


Opal | Level 21

Luckily we don't use times on our VA 7.4, and good to hear 8.2 (and soon 8.3) deals with times better.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 3 in conversation