Data visualization with SAS programming

Lollopop Charts

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

Lollopop Charts

I have SAS Base 9.4.  I have used this code in the past with a different data step and my lollopop chart turned out as expected but this time my hbarparm is not lining up right.  Also, my colors I specified are not showing up.  Does anyone have a solution?

Thanks!

 

Here is the code, attached are the results ...

data data15 ;

input diabet1 risk1 percent1;

cards;

 

1 1 27.5

2 1 74.0

1 2 34.3

2 2 66.5

;

run;

 

/*format percent w/ %*/

Proc format;

value diabet

1="No diabetes"

2="Had diabetes";

value riska

1="High blood pressure"

2="High cholesterol";

run;

 

data demographics;

 

set data15 ;

percent1=percent1/100;

format percent1 PERCENT7.1 risk1 riska. diabet1 diabet.;

run;

 

ods _all_ close;

ods listing gpath="D:\Data";

ods html close;

ods graphics / reset=all outputfmt=emfdual imagename='sastest' width=4.0in height=6.0in noborder;

 

 

proc sgplot data=demographics noborder ;

styleattrs datacontrastcolors=(steelblue steelblue ligr ligr);

hbarparm category=risk1 response=percent1 / group=diabet1 groupdisplay=cluster clusterwidth=0.20

barwidth=0.1 baselineattrs=(thickness=0) ;

scatter y=risk1 x=percent1 / group=diabet1 groupdisplay=cluster

markerattrs=(symbol=circlefilled size=9)

name='percent1' datalabelattrs=(size=6 family="verdana" weight=normal color=black);

xaxis offsetmin=0 display=(noticks noline nolabel novalues)

labelattrs=(size=7 family="verdana" weight=normal )

valueattrs=(size=7 family="verdana" weight=normal );

yaxis display=(nolabel noticks noline) fitpolicy=split

valueattrs=(size=7 family="verdana" weight=normal ) ;

text y=risk1 x=percent1 text=percent1 / group=diabet1 groupdisplay=cluster position=right

textattrs=(size=7 family="verdana" weight=normal color=black);

format risk1 riska. diabet1 diabet. ;

run;


Accepted Solutions
Solution
‎02-23-2018 05:40 PM
SAS Super FREQ
Posts: 1,047

Re: Lollopop Charts

The clusterwidth=0.2 needs to be on the SCATTER and TEXT statements so that they line up with your HBARPARM.

View solution in original post


All Replies
Solution
‎02-23-2018 05:40 PM
SAS Super FREQ
Posts: 1,047

Re: Lollopop Charts

The clusterwidth=0.2 needs to be on the SCATTER and TEXT statements so that they line up with your HBARPARM.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 103 views
  • 0 likes
  • 2 in conversation