How do I convert a character field to numeric so I can use it as a measure instead of a category? For example, I have a field called GPA which was pulled into the data source as a category (text field) because even though a GPA is a number, some values for some people have "N/A" in them (for not applicable). That's why it's a text field. I want to use it as a measure so I can add it to a Visual Analytics report and show averages, standard deviations, etc. There are functions in VA that can convert a numeric field to text, but I don't see anything that converts from character to numeric. I can write SQL code with my eyes closed, but I'm fairly new to VA, so I don't know the "tricks" to get around this limitation. Whatever advice you could give would be greatly appreciated.
WOW, Bruno, this is terrific! All I had to do was plug my field name into the code and it worked perfectly! Thanks so much for the quick reply.
Hi
You can use the Parse operator to convert a string to a number like so:
Parse('number_as_text'n, 'COMMA14.')
Create a new calculated data item and use the expression above
Bruno
WOW, Bruno, this is terrific! All I had to do was plug my field name into the code and it worked perfectly! Thanks so much for the quick reply.
Where did you plug in your field name?
For those that use the Parse function and other string manipulations in SAS Visual Analytics, please note that there may be a performance degradation... http://support.sas.com/kb/57/025.html
Michelle
Thanks for pointing this out.
Bruno
hi bruno_sas,
could you please help me to convert a measure into category.
I have a variable which falls in Category and contains 1001, 1002, 1003 etc. but when using this variable in calculated item it shows as measure.
I already converted that measure as category and its available in Category segmant only but still when using in a filter its coming as measure.
Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF
View now: on-demand content for SAS users
Conversely, how do I treat a measure as a category, i.e. convert the numeric to character, in a data item within an Information Map, for example? Is there an opposite-parse command?
PS: Should I post this as a "new" question?
Please post this as a new questions, since it is not Visual Analytics related.
The proper communitiy would be https://communities.sas.com/t5/SAS-Web-Report-Studio/bd-p/sas_web_report_studio
Bruno
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.