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

Measure to Category conversion in SAS VA

Reply
Frequent Contributor
Posts: 84

Measure to Category conversion in SAS VA


Hi Experts,

 

I using variables Sr No, Emp Code as category that contains all numeric values(like 0001-9999 and 40000-70000) so converted before bringing into LASR and its showing under Category also. But when I am using these variable in calculated column or filter expression its coming as Measure.

 

Actually I want parameterise my report search using these variables so using these variable in filter expression with parameter like:

 

(Emp ID) Contains (Parameter Emp ID)

 

but its coming as measure so not able to use Contain function.

 

 

 

Couldn't figure out the problem.

 

Please help.

 

-Rahul

New Contributor
Posts: 4

Re: Measure to Category conversion in SAS VA

Posted in reply to Rahul_SAS

Hi Rahul

 

You'll be pleased to find this is very quick to fix.

 

As you've found, when a numeric variable comes into VA it defaults to being a measure. 

 

If you want it to be a category, you can easily change it to that.

 

Click on the data item in the left pane

> See properties of that data item at the bottom, with "Classification" shown as "Measure"

> Click on "Measure", and select "Category" from drop down

 

Or can "Right-mouse" click on data item in left pane, and choose "Category" 

 

Done! It now can be used as a category. Of course you can't do calcuations on it now.

 

If you need to use it in both ways, that is as "Category" and "Measure", you can duplicate the data item, call it a different name, and change that one to a "Category".

 

A classic for this is age. You may want age as a "Measure", to get average or max age. And also want age as a "Category", to have certain age groups, so can show bars for each age group.

 

Hope that helps,

 

 

Frequent Contributor
Posts: 84

Re: Measure to Category conversion in SAS VA

Posted in reply to Kiwi_Colin

Thank you sooo much kiwi_colin for your prompt reply.

 

I have already used the solution you have mentioned above.

 

The problem persist even after converting that variable into category as I mentioned in my post that its showing in Category segment only.

 

I am not able to use that converted categorical variable as categorical variable its still coming as Measure when I try to use that in a Calculated column or Filter Expression.

 

-thanks

Occasional Contributor
Posts: 15

Re: Measure to Category conversion in SAS VA

Posted in reply to Kiwi_Colin

Hi Colin,

I have a numeric measure "year" and to convert it into category variable "Year" do i need to duplicate the numeric measure and name it with category variable name

Trusted Advisor
Posts: 1,406

Re: Measure to Category conversion in SAS VA

Posted in reply to sas_viclearner

Hi @sas_viclearner,

 

You would only need to duplicate Year if you need to have both a measure type and a category type for your analysis.

 

I've replied to the question you posted at https://communities.sas.com/t5/SAS-Visual-Analytics/convert-numeric-measure-year-to-category-variabl...

 

Kind Regards,

Michelle

Frequent Contributor
Posts: 84

Measure to Category conversion in SAS VA

Posted in reply to Rahul_SAS

Hi Experts,

 

I using variables Sr No, Emp Code as category that contains all numeric values(like 0001-9999 and 40000-70000) so converted before bringing into LASR and its showing under Category also. But when I am using these variable in calculated column or filter expression its coming as Measure.

 

Actually I want parameterise my report search using these variables so using these variable in filter expression with parameter like:

 

(Emp ID) Contains (Parameter Emp ID)

 

but its coming as measure so not able to use Contain function.

 

 

 

Couldn't figure out the problem.

 

Please help.

 

-Rahul

Occasional Contributor
Posts: 9

Re: Measure to Category conversion in SAS VA

[ Edited ]
Posted in reply to Rahul_SAS

 

If the same dataset is used in multiple reports, and a certain numeric column is always used as a category, it might be a good idea to give the column a format. That will make the column a category in SASVisualAnalyticsDesigner by default.

 

* Format must be stored where Visual Analytics can find it     ;
libname formats "/opt/sas/config/Lev1/SASApp_VA/SASEnvironment/SASFormats/";

* Generic format that can be used for (m)any numeric variable(s)    ;
proc format library=formats.formats;
    value category
        .="Unknown age";
quit;

* Apply format to variables who are to be used as categories. Can be difficult to achieve in the databuilder.
* Do in dataintegration layer if possible.      ;
proc sql noprint;
    create view TEMP_LASR_VIEW_16353 as 
    SELECT
        CLASS.Name length=8 AS Name,
        CLASS.Sex length=1 AS Sex,
        CLASS.Age format=category. length=8 AS Age,
        CLASS.Height length=8 AS Height,
        CLASS.Weight length=8 AS Weight 
    FROM
        sashelp.CLASS CLASS;
quit;

 

 

Ask a Question
Discussion stats
  • 6 replies
  • 891 views
  • 0 likes
  • 5 in conversation