BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Anita_n
Pyrite | Level 9

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;
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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);

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;
Anita_n
Pyrite | Level 9

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?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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);
Anita_n
Pyrite | Level 9

I added minorgrid option to the xaxis which solved the problem

Ksharp
Super User
proc format;
picture positive
low-high= '000000'
;
run;
Anita_n
Pyrite | Level 9

Hello RW9,

thanks for the suggestion. I added minorgrid on the xaxis and this solved the problem. Thank you very much for the help

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2360 views
  • 0 likes
  • 3 in conversation