| www.sas.com > SAS UK > In the Know Homepage | Search | Contact Us |
|
|
|
|
Comparing a profile of a subset to the population profile is a standard practice for demographers. For instance, comparing the car ownership profile of inhabitants of a certain city to the national car ownership distribution. Another example is the comparing the ethnicity profile of customers that purchased a certain product to the full customer base ethnicity profile. It is common practice to compare the profiles using a statistic generally referred to as 'Index'. The following tip describes how to create a meaningful plot of this statistic. Rather plotting the values of the Index it is shifted by 100 to represent the relative difference. A format if automatically created for the presentation of the correct index values. Lets start with a representative demonstration data set:
The following creates a format, a shifted index and the desired plot:
*Create the format;
data Index_Fmt;
fmtname="Index";
do start=-400 to 400;
end=start;
label=compress(start+100)||"%";
output;
end;
run;
proc format cntlin=Index_Fmt;run;
* Calculate the index for plotting;
data _Plot;
set demo;
Index=Subset_Percent/Base_Percent*100-100;
format Index Index.;
run;
*Plot 3;
proc gchart data=_Plot;
title 'Plot3: Index {formatted}';
hbar level/sumvar=Index type=sum DISCRETE raxis=axis2 maxis=axis3 Description="Index" nostats ;
run;quit;
The above produces the desired plot:
|