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 2024

Innovate_SAS_Blue.png

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. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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