BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jacksonan123
Lapis Lazuli | Level 10

I have prepared a needle graph using sgplot.  The graph is okay 

title 'Confidence Interval Range ';
proc sgplot data=boot2 ;
  /*highlow x=ratio low=low high=high / type=line;*/
  highlow x=ratio low=lower_ci high=upper_ci / type=bar  
          lineattrs=(color=black) name='a' attrid=Mono;
  yaxis label='CI range' grid;
  xaxis label='Ratio KaT/KaR' grid values =(0.5 to 2.1 by 0.1);
    keylegend 'a' / location=inside position=bottom;
  run;

and includes my variables CI range and ratio.  However the data set (boot2) has block which I use to categorize my data.  All blocks currently appear in the graph.  My question is there a way to annotate and change the code to allow either the color or line types based upon block to be represented more clearly in the graph? 

 

A sample of data is below containing my variables.

Group Block Upper_CI Lower_CI Ratio
1 0 84 80 0.62
1 0 85 81 0.63
1 0 88 85 0.7
1 0 100 99 0.8
1 0 108 106 1.25
1 0 109 106 1.3
1 0 113 109 1.5
1 0 122 115 2
1 0 125 116 2.1
1 1 104 102 0.62
1 1 104 101 0.63
1 1 104 101 0.7
1 1 90 88 0.8
1 1 98 96 1.25

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Try adding a GROUP and specify the GROUPDISPLAY as cluster. If you want to control the colours, look at a data attribute map.

View solution in original post

3 REPLIES 3
Reeza
Super User
Try adding a GROUP and specify the GROUPDISPLAY as cluster. If you want to control the colours, look at a data attribute map.
jacksonan123
Lapis Lazuli | Level 10
I am only plotting one group at a time so the distinguishing variable would
be block for me not group.

How should this be done since I tried as an interaction (i.e., ratio*block)
and ratio(block) and got an error?

I found this on line related to cluster. If I use this code will I need to
redefine my blocks?



proc sgplot data=sashelp.cars;

where type ne 'Hybrid';

vbar type / response=mpg_city stat=mean group=origin groupdisplay=cluster


Reeza
Super User
GROUP is referencing the term from SGPLOT, nothing to do with your actual data.

highlow x=ratio low=lower_ci high=upper_ci / type=bar group = block groupdisplay=cluster
lineattrs=(color=black) name='a' attrid=Mono;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 752 views
  • 0 likes
  • 2 in conversation