BookmarkSubscribeRSS Feed
Haris
Lapis Lazuli | Level 10

I have a dataset with summary statistics (OR and Confidence Intervals) for a number of centers.  I would like to plot these in an increasing order on the x-axis.  SCATTER does not respect discereorder=data and orders the x-axis by x-variable.  Discrete x-axis routines (VLine, etc.) do not offer a way to display the confidence interval.  So far the best I can do is to suppress the display of x-axis values and use MARKERCHAR to get the values of the center variable.  However, it get the centers inside the figure.


Any suggestions?


data c;

  do TID=1 to 10;

   OR = exp(rannor(0));

   SE = ranuni(0);

   Lower = exp(log(OR)-1.96*SE);

   Upper = exp(log(OR)+1.96*SE);

   L = -1;

   output;

  end;

proc sort data=c; by OR;

quit;

proc sgplot data=c;

  refline 1;

  scatter x=TID y=OR / yerrorlower=Lower yerrorupper=Upper;

  xaxis type=discrete discreteorder=data; /* values are displayed in an increasing order of TID */

proc sgplot data=c noautolegend;

  refline 1;

  scatter x=OR y=OR / yerrorlower=Lower yerrorupper=Upper;

  scatter x=OR y=L / markerchar=TID;

  xaxis type=discrete display=(novalues) label='TID';

quit;

The second plot gets me close to what I want but I suspect that there has to be a way use a different variable to display values of the x-axis.

1 REPLY 1
Haris
Lapis Lazuli | Level 10

I ended up calculating a rank variable for the x-axis and creating a format for the ranks that contain the values of the third variables for the ranks.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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
  • 1 reply
  • 996 views
  • 0 likes
  • 1 in conversation