BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jwperez
Fluorite | Level 6

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.

1 ACCEPTED SOLUTION

Accepted Solutions
jwperez
Fluorite | Level 6

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

13 REPLIES 13
BrunoMueller
SAS Super FREQ

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

jwperez
Fluorite | Level 6

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.

jkovachi
Calcite | Level 5

Where did you plug in your field name?

MichelleHomes
Meteorite | Level 14

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

//Contact me to learn how Metacoda software can help keep your SAS platform secure - https://www.metacoda.com
BrunoMueller
SAS Super FREQ

Michelle

 

Thanks for pointing this out.

 

Bruno

Rahul_SAS
Quartz | Level 8

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.

BrunoMueller
SAS Super FREQ
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
Rahul_SAS
Quartz | Level 8

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.

BrunoMueller
SAS Super FREQ
check the model type for the data item, should be discrete
gsvolba
SAS Employee
Thanks Bruno, this is very helpful! Also in Viya 3.5!
You saved me a lot of time. We meet for a coffee next time you are in Vienna.

Register today and join us virtually on June 16!
sasglobalforum.com | #SASGF

View now: on-demand content for SAS users

ccaulkins9
Pyrite | Level 9

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?

e-SAS regards,

BrunoMueller
SAS Super FREQ

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

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.

Discussion stats
  • 13 replies
  • 20267 views
  • 18 likes
  • 7 in conversation