Exploring, modeling, predicting and reporting with SAS Visual Analytics and SAS Visual Statistics

Converting a category to a measure in VA (character to numeric)

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Converting a category to a measure in VA (character to numeric)

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.


Accepted Solutions
Solution
‎02-23-2016 02:48 PM
New Contributor
Posts: 2

Re: Converting a category to a measure in VA (character to numeric)

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.

View solution in original post


All Replies
SAS Super FREQ
Posts: 620

Re: Converting a category to a measure in VA (character to numeric)

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

Solution
‎02-23-2016 02:48 PM
New Contributor
Posts: 2

Re: Converting a category to a measure in VA (character to numeric)

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.

Super User
Posts: 1,208

Re: Converting a category to a measure in VA (character to numeric)

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

SAS Super FREQ
Posts: 620

Re: Converting a category to a measure in VA (character to numeric)

Michelle

 

Thanks for pointing this out.

 

Bruno

Contributor
Posts: 30

Re: Converting a category to a measure in VA (character to numeric)

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?

SAS Super FREQ
Posts: 620

Re: Converting a category to a measure in VA (character to numeric)

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

Post a Question
Discussion Stats
  • 6 replies
  • 1670 views
  • 4 likes
  • 4 in conversation