Help using Base SAS procedures

SGPLOT vline xaxis statement

Reply
Occasional Contributor
Posts: 12

SGPLOT vline xaxis statement

I'm working on a vline plot of means (with CIs) over time. My time variable is in days which range from 0 to 194 and I don't want a CI for the many days that will squeeze on the x-axis, so I used the xaxis values= statement but it's being ignored. The documentation says it will be ignored if the values statement creates over 1,000 points, but this doesn't so I'm not sure what I'm doing wrong.

ods graphics on;

proc sgplot data=alldat;

  vline timedays/response=alkphos

          stat=mean

          limits=both

          limitstat=clm

          markers datalabel;

  xaxis values=(0 to 250 by 50);

run;

(I have also tried "0 to 200 by 50" and "-50 to 250 by 50" with the same result)

Respected Advisor
Posts: 4,644

Re: SGPLOT vline xaxis statement

Can you describe how you would like your graph to look? - PG

PG
Occasional Contributor
Posts: 12

Re: SGPLOT vline xaxis statement

Ideally the x-axis is time with ticks at 0, 50, 100, 150, and 200 days only; the y-axis is alk phos. It will show the mean and 95% CL for alk phos at each of the 5 time points. I am getting all of that now except that there are something like 30 time points and the graph looks cluttered.

Super User
Posts: 10,485

Re: SGPLOT vline xaxis statement

If you only want 5 time points you have a couple options. One is to use a WHERE clause to restrict data to those values of x.

If you are looking to combine things such that time points from say 25 to 75 display and are considered as time value 50 the easiest might be to create a format centered.

Some thing like:

proc format;

value myx

-25  -  25 = '  0'

25 <-  75 = ' 50'

75 <- 125 = '100'

125 <- 175 = '150'

175 <- 225 = '200'

;

run;

and in your sgplot syntax add

format timedays myx. ;


Respected Advisor
Posts: 4,644

Re: SGPLOT vline xaxis statement

Another option is to show the line for all points and the error bars only at your desired points as in :

data allDatGraph;
set alldat;
if mod(timedays,50)=0 then alkPhosSpec=alkPhos;
run;

ods graphics on;
proc sgplot data=allDatGraph;
  vline timedays/response=alkphos
          stat=mean;
  vline timedays/response=alkphosSpec
          stat=mean
          limits=both
          limitstat=clm
          break markers datalabel;
  xaxis fitpolicy=thin;
run;

PG

PG
Ask a Question
Discussion stats
  • 4 replies
  • 596 views
  • 0 likes
  • 3 in conversation