Hi.
ON SAS VA I have to perform a subtraction among two variable, representing two years, types are character. But SAS VA give me mistake. Have you advice?
Thanks to everyone 🙂
Hello,
Dates in Visual Analytics are SAS dates and can be tricky to perform basic math on. The best approach to handling them will depend on what exactly you are trying to do.
Sam
Hello @pablo29
Did I understand correctly that your year variable is actually a character string, not actual numbers/date? If this is the case then you first need to create a new date type variable from the character string. You can do this f.ex. by using Substring, Parse and DateFromMDY functions.
Is your year variable just four digits (2020) or more like a date (2020-08-17)? You could create a numeric variable just for year, but I personally prefer to create date variables with year format as it enables use of VA's periodic operators.
You can calculate differences between date variables by utilizing TreatAs (_number_) function. First you convert your date type variable to numbers, then calculate the difference, and finally convert number type variable back to date type variable by using TreatAs second time. It's actually very easy and straightforward even though it might not sound like it.
Btw. which version of VA you have?
Best regards,
Petri
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.
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.