*specify the path to where the files should be saved;
ods listing gpath='/folders/myfolders/edgeci_plots/ritalinla/';
*specify the output type;
ods graphics / imagename='mygraph' imagefmt=png;
title 'Confidence Interval Range Kslow';
proc sgplot data=boot3 ;
/*highlow x=ratio low=low high=high / type=line;*/
highlow x=ratio low=lower_ci high=upper_ci / type=bar group=block
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=outside position=bottom /LEGENDLABEL="PAUC03L";*/
KEYLEGEND/noborder title='PAUCS:';
run;
quit;
The attached code works, however the legend fails to contain all of my blocks, specifically PAUC712L and PAUC71U.
The data is below. All of the data appear in the graph. Can someone tell me either why all of the data do not appear in the legend
or some way to control what appears in the legend? I have tried several methods without success.
Group | Block | Upper_CI | Lower_CI | Ratio |
1 | PAUC03L | 85 | 80 | 0.5 |
1 | PAUC03L | 94 | 88 | 0.55 |
1 | PAUC03L | 95 | 91 | 0.65 |
1 | PAUC03L | 96 | 92 | 0.7 |
1 | PAUC03L | 97 | 94 | 0.8 |
1 | PAUC03U | 103 | 101 | 1.25 |
1 | PAUC03U | 101 | 100 | 1.3 |
1 | PAUC03U | 101 | 100 | 1.4 |
1 | PAUC03U | 109 | 105 | 1.7 |
1 | PAUC03U | 104 | 100 | 2 |
1 | PAUC37L | 106 | 103 | 0.5 |
1 | PAUC37L | 98 | 93 | 0.55 |
1 | PAUC37L | 102 | 101 | 0.65 |
1 | PAUC37L | 102 | 101 | 0.7 |
1 | PAUC37L | 101 | 100 | 0.8 |
1 | PAUC37U | 99 | 98 | 1.25 |
1 | PAUC37U | 99 | 98 | 1.3 |
1 | PAUC37U | 99 | 98 | 1.4 |
1 | PAUC37U | 97 | 96 | 1.7 |
1 | PAUC37U | 98 | 97 | 2 |
1 | PAUC712L | 106 | 104 | 0.5 |
1 | PAUC712L | 106 | 105 | 0.55 |
1 | PAUC712L | 103 | 101 | 0.65 |
1 | PAUC712L | 102 | 101 | 0.7 |
1 | PAUC712L | 101 | 100 | 0.8 |
1 | PAUC712U | 99 | 98 | 1.25 |
1 | PAUC712U | 100 | 99 | 1.3 |
1 | PAUC712U | 100 | 99 | 1.4 |
1 | PAUC712U | 98 | 95 | 1.7 |
1 | PAUC712U | 100 | 98 | 2 |
When you comment out the LINEATTRS from the SGPANEL, the fill colors return and also the legend contains all of the line types. The line size was too large and was blocking the graphs underneath.
This solves the issue.
Please provide the data following these instructions, so that we can make use of your exact data and see if we can provide advice.
@jacksonan123 you have some really neat code you are requesting assistance in debugging.
Your data sample you have supplied in the original posting looks like Excel type of a format,
then in your reply you pasted a copy of the original sample data which if you look at that is exactly what we get when we put that sample data into a SAS session. It is really unreadable and messy.
To assist with your request you need to convert your data sample into a simple SAS data step with a dateline statement. I would suggest you edit your reply to @PaigeMiller so that this request is not so messy in reading so others might assist without getting a head-ack scrolling. Thanks
How to create a data-step version of your data
https://communities.sas.com/t5/help/faqpage/faq-category-id/posting#posting
https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...
How to Add attachments
https://communities.sas.com/t5/Community-Memo/Adding-attachments-to-your-communities-posts/ba-p/4647...
Adding .. we need data as SAS data step code (links have been provided explaining how to do this); we don't want and can't use data in any other format. In other words, if you want help on this, you need to do a little extra work to provide your data in the requested format.
Group Block Upper_CI Lower_CI Ratio 1 PAUC03L 85 80 0.5 1 PAUC03L 94 88 0.55 1 PAUC03L 95 91 0.65 1 PAUC03L 96 92 0.7 1 PAUC03L 97 94 0.8 1 PAUC03U 103 101 1.25 1 PAUC03U 101 100 1.3 1 PAUC03U 101 100 1.4 1 PAUC03U 109 105 1.7 1 PAUC03U 104 100 2 1 PAUC37L 106 103 0.5 1 PAUC37L 98 93 0.55 1 PAUC37L 102 101 0.65 1 PAUC37L 102 101 0.7 1 PAUC37L 101 100 0.8 1 PAUC37U 99 98 1.25 1 PAUC37U 99 98 1.3 1 PAUC37U 99 98 1.4 1 PAUC37U 97 96 1.7 1 PAUC37U 98 97 2 1 PAUC712L 106 104 0.5 1 PAUC712L 106 105 0.55 1 PAUC712L 103 101 0.65 1 PAUC712L 102 101 0.7 1 PAUC712L 101 100 0.8 1 PAUC712U 99 98 1.25 1 PAUC712U 100 99 1.3 1 PAUC712U 100 99 1.4 1 PAUC712U 98 95 1.7 1 PAUC712U 100 98 2
I have inserted code based upon the link for data less than 50 lines. Hopefully this will allow the data to be seen although some did shift to the left.
How to Add attachments
https://communities.sas.com/t5/Community-Memo/Adding-attachments-to-your-communities-posts/ba-p/4647...
This works for me
data boot3;
input Group :$1 Block :$ Upper_CI :8. Lower_CI :8. Ratio :8.;
datalines;
1 PAUC03L 85 80 0.5
1 PAUC03L 94 88 0.55
1 PAUC03L 95 91 0.65
1 PAUC03L 96 92 0.7
1 PAUC03L 97 94 0.8
1 PAUC03U 103 101 1.25
1 PAUC03U 101 100 1.3
1 PAUC03U 101 100 1.4
1 PAUC03U 109 105 1.7
1 PAUC03U 104 100 2
1 PAUC37L 106 103 0.5
1 PAUC37L 98 93 0.55
1 PAUC37L 102 101 0.65
1 PAUC37L 102 101 0.7
1 PAUC37L 101 100 0.8
1 PAUC37U 99 98 1.25
1 PAUC37U 99 98 1.3
1 PAUC37U 99 98 1.4
1 PAUC37U 97 96 1.7
1 PAUC37U 98 97 2
1 PAUC712L 106 104 0.5
1 PAUC712L 106 105 0.55
1 PAUC712L 103 101 0.65
1 PAUC712L 102 101 0.7
1 PAUC712L 101 100 0.8
1 PAUC712U 99 98 1.25
1 PAUC712U 100 99 1.3
1 PAUC712U 100 99 1.4
1 PAUC712U 98 95 1.7
1 PAUC712U 100 98 2
;
*ods listing gpath='/folders/myfolders/edgeci_plots/ritalinla/';
*specify the output type;
*ods graphics / imagename='mygraph' imagefmt=png;
title 'Confidence Interval Range Kslow';
proc sgplot data=boot3 ;
/*highlow x=ratio low=low high=high / type=line;*/
highlow x=ratio low=lower_ci high=upper_ci / type=bar group=block
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=outside position=bottom /LEGENDLABEL="PAUC03L";*/
KEYLEGEND/noborder title='PAUCS:';
run;
quit;
I also get those blocks you say were not appearing.
format block $char20.
try format block $20.
Works for me
your block variable might not be large enough and thus truncating the longest block names.
Whenever some people respond "Works for me," I suspect that the OP is running an older version of SAS than the responders. Please provide your version of SAS by pasting the result from the SAS log after you submit the statement
%put &=SYSVLONG4;
When you comment out the LINEATTRS from the SGPANEL, the fill colors return and also the legend contains all of the line types. The line size was too large and was blocking the graphs underneath.
This solves the issue.
so are you saying @jacksonan123 that the sample size provided was to small for us to recreate the issue in order to provide the correct solution?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.