Data visualization with SAS programming

PROC SGPLOT Selected TIck on X-axis

Reply
Contributor
Posts: 41

PROC SGPLOT Selected TIck on X-axis

Hello,

 

I am trying to display a lab test values for a particular test by visit. There are lot of "unscheduled" visits in the data.

I want to display the values from unscheduled in the graph, but on x-axis I do not want to display "unscheduled"

visits. I only want to display schedule visits like - baseline, week2, week 2, etc.

 

How can this be done ?

 

For ex :

 

Visit                  Values

Baseline              20

Week 1                25

Unschedule 1.1   26

Week 2                27

Unschedule 2.1   28

....

 

I want to display all the above values but in x-axis I want to display only - Baseline, Week 1, Week 2, etc no unschedule visits.

 

 

SAS Super FREQ
Posts: 1,136

Re: PROC SGPLOT Selected TIck on X-axis

Use the VALUES option on the x-axis to include only the values you want.  Provide a format to display the numeric values as the text description on the axis.

Contributor
Posts: 41

Re: PROC SGPLOT Selected TIck on X-axis

Thanks Sanjay. I want all the values to be displayed - including unscheduled visits but I don't want to show the "Unscheduled" visits labels on the x-axis. Basically, I want to display values from all the visits including unschedule visits on the graph but on the x-axis label, I want to show label for selected visits (only schedule visits not unscheduled). I don't know if it is possible. 

 

For ex - I would like to display data from unschedule visits 1.1 but I do not want this label to appear on x-axis. This value should only be in graph. 

Super User
Super User
Posts: 7,691

Re: PROC SGPLOT Selected TIck on X-axis

[ Edited ]

Try using the example Sanjay has provided and come back with any further questions.  Values option specifies the values which appear on the axis line, it does not restrict any data.

 

Also, have a look at his excellent blog on Graphs - it covers pretty much anything you can think of:

http://blogs.sas.com/content/graphicallyspeaking/

Contributor
Posts: 41

Re: PROC SGPLOT Selected TIck on X-axis

I tried Sanjay's suggestion but it is not working. There are lot of visits in the data. Here is the code I am using.

 

proc sgplot data = lb ;
series x=visitnum y=lbstresn / group = usubjid markers lineattrs = (thickness = 2) ;
xaxis label = "Study Weeks"  type = linear 
values = (1 1.02 2 5.01 6 7 7.01 7.02 8 8.01 8.02 9 9.01 9.02 10 10.01 10.02 10.03 10.04 11 11.01 11.02 11.03 12
12.01 13 13.01 14 14.01 15 16 16.01 17 17.01 18 19 20 21 22 22.01 23 23.01 24 25 25.01 26 27 28 29
30 30.01 30.02 31 31.01 31.02 32 32.01 33 33.01 33.02 33.03 33.04 33.05 33.06 33.07 34 34.01 34.02
34.03 34.04 34.05 34.06 34.07 35 35.01 35.02 35.03 35.04 36 36.01 36.02 36.03 36.05 36.06 36.07 36.08
36.09 36.1 36.11) valuesformat = tick. ;
yaxis label = "ALT (IU/L)" values = (0 to 100 by 10) display = all;
keylegend / location = outside position = bottom valueattrs = (size=7) title = 'Subject ID';

refline 43 / axis = y lineattrs = (pattern = shortdash) label = 'ULN' labelpos = max;
run;

 

The tick format is 

 

Proc format;

value tick
1 = 'Screening'
2 = 'Baseline'
6 = 'Week 1(Day 8)'
7 = 'Week 2'
8 = 'Week 3'
9 = 'Week 4'
10 = 'Week 5'
11 = 'Week 6'
12 = 'Week 7'
15 = 'Week 8'
18 = 'Week 9'
21 = 'Week 10'
24 = 'Week 11'
27 = 'Week 12'
30 = 'Week 13'
31 = 'Week 14'
32 = 'Week 15'
33 = 'Week 16'
34 = 'Week 20'
35 = 'Week 28'
36 = 'Week 36'
other = ' '
;
run;

 

 

SAS Super FREQ
Posts: 925

Re: PROC SGPLOT Selected TIck on X-axis

The VALUES list should contain only the numbers 1 throught 36. The values not directly on 1 - 36 will still plot correctly, since this is a linear axis.

Contributor
Posts: 41

Re: PROC SGPLOT Selected TIck on X-axis

When I change type from "linear" to "discrete" it is plotting all the ticks on x-axis but it is not picking the format.

For example I see ticks - 1, 1.02, 2, etc but these values are not getting displayed as per the format. Basiaclly,

the format tick. is not working when I change type to discrete. What am I missing ? 

Ask a Question
Discussion stats
  • 6 replies
  • 870 views
  • 0 likes
  • 4 in conversation