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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 889 views
  • 0 likes
  • 3 in conversation