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 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
  • 3 replies
  • 295 views
  • 0 likes
  • 3 in conversation