I used sgplot to create this population pyramid. I used the picture format as in the program. I want the xaxis values to be displayed as shown but 0 should be displayed as one digit instead of 6 digits as its showing. Is there any way I can do that?
Below is my code:
proc format;
picture positive
low-high= '999999'
;
run;
proc sgplot data = population2017 noautolengend ;
format Male Female positive.;
hbarparm category= agegroup response=Male/ barwidth=1 fillattrs=(color=blue baselineattrs=(thickness=0)
outlineattrs=(color=black thickness= 0) missing;
hbarparm category= agegroup response=Female/ barwidth=1 fillattrs=(color=red) baselineattrs=(thickness=0)
outlineattrs=(color=black thickness=0) missing;
xaxis values=(-200000 to 200000 by 100000) display=(nolabel) grid ;
yaxis display=(nolabel) offsetmin=0 offsetmax=0;
run;
Could you just change the format to character?
proc format; value $tmp -200000="-2" -100000=" " 0=0 100000=" " 200000="2"; run;
Alternatively you would need to have major ticks as the 20000, 0, 20000 and then minor ticks without labels at all five points. Haven't got anything to work on, but something like;
xaxis major=(-20000 0 200000) minor=(-20000 -10000 0 10000 20000);
You could create another format to be applied to the xaxis something like:
proc format; value tmp -200000=-2 -100000=-1 0=0 100000=1 200000=2; run;
Thanks, it worked fine.
I have another question: if I want for example the first grid on the xaxis to have a value (which is here 200000), the next grid to be displayed but without any value then the next with value 100000 and so on. I mean a gid should always be left without a value between
those with values. How do I do that?
Could you just change the format to character?
proc format; value $tmp -200000="-2" -100000=" " 0=0 100000=" " 200000="2"; run;
Alternatively you would need to have major ticks as the 20000, 0, 20000 and then minor ticks without labels at all five points. Haven't got anything to work on, but something like;
xaxis major=(-20000 0 200000) minor=(-20000 -10000 0 10000 20000);
I added minorgrid option to the xaxis which solved the problem
proc format;
picture positive
low-high= '000000'
;
run;
Hello RW9,
thanks for the suggestion. I added minorgrid on the xaxis and this solved the problem. Thank you very much for the help
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: