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 now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.