Dear all,
Does anyone know how to specify the value for ticks on axis as percentage (e.g. '8%') instead of number (e.g. '8') for a scatter plot ?
I used 'Proc sgplot' to create a scatter plot for proportion of diabetes in male and female. The Y axis is proportion and I want to display percentage here. Thanks a lot!
Best,
Feng Liang
Dear Jagadishkatam,
The following are my codes:
data pdi;
INPUT Gender $ Proportion;
cards;
Male 10.6
Female 28.0
;
RUN;
PROC SGPLOT DATA=pdi;
SCATT...
The values for variable 'proportion' is percentage (10.6% and 28%) itself. I cannot categorize them again. Thanks!
Regards,
Feng Liang
Sorry, the codes were not posted properly. I post them again.
data pdi;
INPUT Gender $ Proportion;
cards;
Male 10.6
Female 28.0
;
RUN;
PROC SGPLOT DATA=pdi;
SCATTER Y=Proportion X=gender/ datalabel=proportion ;
YAXIS VALUES=(0 TO 40 BY 10) LABEL="Proportion " LABELATTRS=(size=13 );
XAXIS LABEL="Proportion of diabetes by gender" ;
RUN;QUIT;
Thanks!
Feng Liang
In that case you coudl try something as below
data pdi;
INPUT Gender $ Proportion;
cards;
Male 10.6
Female 28.0
;
RUN;
proc format;
value pct
10.6='10.6%'
28.0='28.0%'
;
use this format on the variable in proc sgplot
Hello,
I would just divide your proportions by 100 and add the percent12.1 format to it. I had to adjust the y axis values (didn't change your label yet) afterwards. Here's what I got with your code:
data pdi;
input gender $ proportion;
cards;
Male 10.6
Female 28.0
;
run;
data pdi2;
set pdi;
proportion=proportion/100;
run;
ods graphics /reset;
proc sgplot data=pdi2;
scatter y=proportion x=gender / datalabel=proportion;
yaxis values=(0 to 0.4 by 0.1) Label='Proportion' labelattrs=(size=13);
xaxis label='Proportion of diabetes by gender';
format proportion percent12.1;
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.