Being that 2013 is the International Year of Statistics, I wanted to make sure everyone knows how to handle my favorite statistic - percent (%) - in SAS!
I often see data in spreadsheets/csv/etc that purport to represent "percents"... but you have to be a bit careful when working with those values. Are they the raw numeric values, or are they the formatted values?
In SAS, to represent 12.5%, you'll want to store the numeric value .125, and then apply the 'percent.' format so that it will print out (in tables, graphs, etc) as 12.5%.
Something like this...
format y percent7.1;
proc print data=foo;
That was simple enough!... but what about a graph where you want to show the value rounded to a whole percent on the axis, but show more precision (let's say 2 decimal places) in the pointlabels for the markers in the plot???
Yes - you can do that in SAS!
I recommend using the simple format statement to control the graph's axis, and then create a special extra/temporary text variable containing the marker values, formatted to show a percent with 2 decimal places, to use as the pointlabels.
length custom_text $50;
symbol1 color=red value=circle height=6 pointlabel=(height=11pt color=blue "#custom_text");
proc gplot data=my_data;
format percent_value percent7.0;
Now the axis shows nice/rounded values (with no decimal places), and the pointlabels show 2 decimal places:)
Hopefully this simple example will help teach you the basics, so you can customize your graphs in endless ways!
Here is the complete SAS code for the above example.