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!
The following are my codes:
The values for variable 'proportion' is percentage (10.6% and 28%) itself. I cannot categorize them again. Thanks!
Sorry, the codes were not posted properly. I post them again.
INPUT Gender $ Proportion;
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" ;
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 open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.