Data visualization with SAS programming

Graphing a frequency distributions chart to compare manipulator and non-manipulator

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

Graphing a frequency distributions chart to compare manipulator and non-manipulator

Hi,

I would like to graph a frequency distributions chart to compare the distribution of manipulator and non-manipulator.

 

However, the frequency of manipulator is really small, so i want to multiply a number on the frequency of distrubution for manipulator in order to allow easier visual comparison with the much larger sample of non-manipulator.

 

I use proc sgplot. How can I make it work?

 

Thank you very much for your help.

 

 


Accepted Solutions
Solution
‎02-05-2017 11:52 PM
SAS Super FREQ
Posts: 3,232

Re: Graphing a frequency distributions chart to compare manipulator and non-manipulator

If you want a kernel density estimate of the FREQ variable, you can use 

proc sgplot data=em;
density freq / type=kernel group=em;
run;

If you want to form a histogram, but plot the frequencies as a series, you can use PROC UNIVARIATE to bin the data and the SERIES statement to plot the binned frequencies:

 

proc univariate data=em noprint;
class em;
histogram freq  / outhist=out
            midpoints=(0 to 0.8 by 0.05);
run;

proc sgplot data=out;
series x=_midpt_  y=_count_ / group=em;
run;

View solution in original post


All Replies
SAS Super FREQ
Posts: 3,232

Re: Graphing a frequency distributions chart to compare manipulator and non-manipulator

Instead of multiplying, plot both histograms or bar charts on the percentage scale. For example, this is how you can plot percentage of males and females on the same bar chart:

 

proc sgplot data=sashelp.class;
vbar age / group=sex stat=percent groupdisplay=cluster;
run;

If you have a continuous variable, you can use  comparative histograms to compare the distribution across groups.

Occasional Contributor
Posts: 13

Re: Graphing a frequency distributions chart to compare manipulator and non-manipulator

Thank you very much for your prompt response. But it has to be the frequency scale. D you know how to do it? thank you
SAS Super FREQ
Posts: 3,232

Re: Graphing a frequency distributions chart to compare manipulator and non-manipulator

I don't understand why you say "it has to be the frequency scale."  To compare absolute counts, plot the data on the count scale. To compare the relative proportions, plot on the percentage scale.

 

Do you have some sampling scheme in which you oversampled one category? For example, does each male in your data represent 10 members of the population but each female represents 100?  Even then, I think plotting proportions are the way to go.

Occasional Contributor
Posts: 13

Re: Graphing a frequency distributions chart to compare manipulator and non-manipulator

Hi Rick,

 

Sorry for making you confuse.
I have matched one manipulator to five non-manipulator, and i need to graph a frequency distribution char to compare the difference of ditribution between manipulator and non-manipulator.

 

Please find the attached figure. I need to do the same thing as the enclosed figure.

 

Thank you very much for your help.

Attachment
SAS Super FREQ
Posts: 3,232

Re: Graphing a frequency distributions chart to compare manipulator and non-manipulator

Well, I still don't like it, but you can do it by using a FREQ variable. Here is an example in which each female in the data set  represents 5 females:

 

data FakeData;
set sashelp.class;
if sex="F" then freq=5;
else freq=1;
run;

proc sgplot data=FakeData;
vbar age / group=sex freq=freq groupdisplay=cluster;
run;
Occasional Contributor
Posts: 13

Re: Graphing a frequency distributions chart to compare manipulator and non-manipulator

Thank you for your help, though it is still different from what i need.

 

Regards,

SAS Super FREQ
Posts: 3,232

Re: Graphing a frequency distributions chart to compare manipulator and non-manipulator

If you want a line instead of bars, just use the VLINE statement instead of VBAR.

 

If you have a continuous variable, use the DENSITY statement.

 

If you post some sample data, I'm sure that someone can give you what you need.

 

 

Occasional Contributor
Posts: 13

Re: Graphing a frequency distributions chart to compare manipulator and non-manipulator

[ Edited ]

Thank you. the following is the sample data. i want to compare the difference of  distribution (frequency) of Estimated probability between em=1 and em=0.

 

Global CompanyData Year -emEstimated Probability
KeyFiscal
  
  
1173199910.50883
137377199900.53093
1173199910.50883
31015199900.36718
1173199910.50883
8388199900.45892
1173199910.50883
133729199900.52904
1173199910.50883
61553199900.6904
1173200010.48688
63038200000.53392
1173200010.48688
26038200000.67335
1173200010.48688
15758200000.56561
1173200010.48688
62874200000.49828
1173200010.48688
143526200000.48667
1173200110.48896
15758200100.43567
1173200110.48896
2299200100.4265
1173200110.48896
24982200100.52106
1173200110.48896
Solution
‎02-05-2017 11:52 PM
SAS Super FREQ
Posts: 3,232

Re: Graphing a frequency distributions chart to compare manipulator and non-manipulator

If you want a kernel density estimate of the FREQ variable, you can use 

proc sgplot data=em;
density freq / type=kernel group=em;
run;

If you want to form a histogram, but plot the frequencies as a series, you can use PROC UNIVARIATE to bin the data and the SERIES statement to plot the binned frequencies:

 

proc univariate data=em noprint;
class em;
histogram freq  / outhist=out
            midpoints=(0 to 0.8 by 0.05);
run;

proc sgplot data=out;
series x=_midpt_  y=_count_ / group=em;
run;
Post a Question
Discussion Stats
  • 9 replies
  • 177 views
  • 0 likes
  • 2 in conversation