BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sas_it
Quartz | Level 8
I am having the variables with value 0 an 1. So in measure it shows count. But when i convert that to category as i want to create hierarchy does the count differs as it has 0 and 1 as values.
1 ACCEPTED SOLUTION

Accepted Solutions
acordes
Rhodochrosite | Level 12

No, you have to create a new data item.

call it character expression of your numerical variable.

use the FORMAT operator and place the numerical variable inside, choose best12. for the format.

this newly created data item works in hierarchies.

View solution in original post

6 REPLIES 6
acordes
Rhodochrosite | Level 12

I don't understand 100% your question.

BUT perhaps this may be your solution:

Depending on the context the "convert to category" option still treats the "categorical" variable as numeric preventing you from using it in a hierarchy for example.

You can overcome this by creating a categorical expression of your numerical variable by creating a calculated item "_ch_numvar" in this manner:

format(numeric_variable, best12.)

then it behaves like truly categorical

sas_it
Quartz | Level 8
Thank you for your suggestion but in hierarchy only category items are accepted. Can I merge two or more categories ?
acordes
Rhodochrosite | Level 12

the newly created item _ch_numvar is categorical.

This is achieved by using the format operator on a numerical variable. give it a try

sas_it
Quartz | Level 8
As I have to create hierarchy so I tried to convert to category from numeric and created category of that variable and chose 1 and created hierarchy. Is this correct?
acordes
Rhodochrosite | Level 12

No, you have to create a new data item.

call it character expression of your numerical variable.

use the FORMAT operator and place the numerical variable inside, choose best12. for the format.

this newly created data item works in hierarchies.

sas_it
Quartz | Level 8
For the calculated item variable i am checking if a=1 then return 1 else 0 for count. As variable contains 0 0r1 but i require 1(count of it). Is it correct?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6 replies
  • 1714 views
  • 3 likes
  • 2 in conversation