BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
lone0708
Fluorite | Level 6

Hello all, 

i am creating a really simple sgplot, where i want to use an xaxistable. My problem is, that the xaxistable is not aligned with the x-axis. It shows too many observations. 

How can i get the values to align with the values on the x-axis?

 

example data:

data have;

input time count cumulative_percent;

datalines;

1 4 10

2 10 25

3 2 5

4 20 50

5 4 10

;

run;

proc sgplot data = abc;
series x=time y = count;
taxis values = 0 to 52 by 5);
xaxistable cumulative_percent;run;

lone0708_0-1664192988684.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

You might need to create a temporary dataset where those unwanted values are set to missing.

 

Example:

/* Create sample data for demonstration */

data have;
do time=0 to 52;
  count=round(pdf('chisq',time,3)*1e4+108.9);
  cumulative_percent+count/150;
  output;
end;
label time='use_in_weeks';
run;

/* Restrict values for x-axis table to tick marks */

data want;
set have;
if mod(time,5) then cumulative_percent=.;
format cumulative_percent 5.1;
run;

/* Create the plot with blanks between the x-axis table items */

options missing=' ';
proc sgplot data = want;
series x=time y = count;
xaxis values = (0 to 52 by 5);
xaxistable cumulative_percent / label='cumul. %';
run;

View solution in original post

3 REPLIES 3
Ksharp
Super User
data have;
input time count cumulative_percent;
datalines;
1 4 10
2 10 25
3 2 5
4 20 50
5 4 10
;
run;

proc sgplot data = have;
series x=time y = count;
*xaxis values =( 0 to 52 by 5);
xaxistable cumulative_percent/x=time;
run;

 

Ksharp_0-1664196839438.png

 

lone0708
Fluorite | Level 6

Thank you for your answer, 

When i add the / x=time to my code, i still have way to many datapoints at my graph. 
I have calculated the cumulative percent for each observation, but on my x-axis i have chosen only to show by 5. Can i get the xaxistable to only show by 5 as well?

FreelanceReinh
Jade | Level 19

You might need to create a temporary dataset where those unwanted values are set to missing.

 

Example:

/* Create sample data for demonstration */

data have;
do time=0 to 52;
  count=round(pdf('chisq',time,3)*1e4+108.9);
  cumulative_percent+count/150;
  output;
end;
label time='use_in_weeks';
run;

/* Restrict values for x-axis table to tick marks */

data want;
set have;
if mod(time,5) then cumulative_percent=.;
format cumulative_percent 5.1;
run;

/* Create the plot with blanks between the x-axis table items */

options missing=' ';
proc sgplot data = want;
series x=time y = count;
xaxis values = (0 to 52 by 5);
xaxistable cumulative_percent / label='cumul. %';
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 3 replies
  • 1853 views
  • 0 likes
  • 3 in conversation