Exploring, 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)

Posted in reply to Bruno_SAS

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: 708

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)

Posted in reply to Bruno_SAS

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.

Trusted Advisor
Posts: 1,319

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

Posted in reply to Bruno_SAS

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: 708

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

Posted in reply to MichelleHomes

Michelle

 

Thanks for pointing this out.

 

Bruno

Contributor
Posts: 64

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

Posted in reply to Bruno_SAS

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.

SAS Super FREQ
Posts: 708

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

Posted in reply to Rahul_SAS
Simply change the measure into a category on the data item in question. However I would recommend to have all category variables defined as character variable and likewise a measure should always be numeric, prior to loading the data into the LASR server
Contributor
Posts: 64

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

Posted in reply to Bruno_SAS

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.

SAS Super FREQ
Posts: 708

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

Posted in reply to Rahul_SAS
check the model type for the data item, should be discrete
Contributor
Posts: 32

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: 708

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

Posted in reply to ccaulkins9

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 3251 views
  • 4 likes
  • 5 in conversation