I have a column on my dataset that has date values, but the variable is Catregorical. I am looking for a way to get the month values. For example, the data I have is Dec 08 2022 (categorical). I would like to get the 08, using VA interface. I'd use Calculated Item, and use Text operators but then they require numerical inputs. So, this idea didn't work.
Can I achieve what I am trying to do in VA? If yes, how?
This is a common issue, especially if you are importing CSV/TSV data. The Parse() operator is what you need.
interprets a numeric or datetime value from the input string. Click the format field to select the format that is used to interpret the string. The output from the Parse operator is either a number or a datetime value, depending on the format that you select.
Parse('15JAN2013', 'DATE9.') returns 15JAN2013 as a date value.
Let us know if that helps,
Thanks for the suggestion. Actually, I tried it but then all I had in the calculated item was missings. Here is how I created the Calculated Item using Parse:
This is the result on the left hand side column (all missing) created based on the right hand side column.
It looks like your date values have spaces in them: 01 JAN 2023
You might try different formats to see if there is one that will parse this.
You can also try wrapping the date value in the RemoveBlanks() operator.
That would look something like this:
Parse(RemoveBlanks('Date'n, _All_), 'Date9.')
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.