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
*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. 

GroupBlockUpper_CILower_CIRatio
1PAUC03L85800.5
1PAUC03L94880.55
1PAUC03L95910.65
1PAUC03L96920.7
1PAUC03L97940.8
1PAUC03U1031011.25
1PAUC03U1011001.3
1PAUC03U1011001.4
1PAUC03U1091051.7
1PAUC03U1041002
1PAUC37L1061030.5
1PAUC37L98930.55
1PAUC37L1021010.65
1PAUC37L1021010.7
1PAUC37L1011000.8
1PAUC37U99981.25
1PAUC37U99981.3
1PAUC37U99981.4
1PAUC37U97961.7
1PAUC37U98972
1PAUC712L1061040.5
1PAUC712L1061050.55
1PAUC712L1031010.65
1PAUC712L1021010.7
1PAUC712L1011000.8
1PAUC712U99981.25
1PAUC712U100991.3
1PAUC712U100991.4
1PAUC712U98951.7
1PAUC712U100982

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jacksonan123
Lapis Lazuli | Level 10

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.

View solution in original post

15 REPLIES 15
PaigeMiller
Diamond | Level 26

Please provide the data following these instructions, so that we can make use of your exact data and see if we can provide advice.

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

--
Paige Miller
jacksonan123
Lapis Lazuli | Level 10
I put the data in the original post. Not sure why it didn't show up, but
here it is again.


Group

Block

Upper_CI

Lower_CI

Ratio

Parameter

nGroup


1

PAUC03L

85

80

0.5

Kafast

Kafast


1

PAUC03L

94

88

0.55

Kafast

Kafast


1

PAUC03L

95

91

0.65

Kafast

Kafast


1

PAUC03L

96

92

0.7

Kafast

Kafast


1

PAUC03L

97

94

0.8

Kafast

Kafast


1

PAUC03U

103

101

1.25

Kafast

Kafast


1

PAUC03U

101

100

1.3

Kafast

Kafast


1

PAUC03U

101

100

1.4

Kafast

Kafast


1

PAUC03U

109

105

1.7

Kafast

Kafast


1

PAUC03U

104

100

2

Kafast

Kafast


1

PAUC37L

106

103

0.5

Kafast

Kafast


1

PAUC37L

98

93

0.55

Kafast

Kafast


1

PAUC37L

102

101

0.65

Kafast

Kafast


1

PAUC37L

102

101

0.7

Kafast

Kafast


1

PAUC37L

101

100

0.8

Kafast

Kafast


1

PAUC37U

99

98

1.25

Kafast

Kafast


1

PAUC37U

99

98

1.3

Kafast

Kafast


1

PAUC37U

99

98

1.4

Kafast

Kafast


1

PAUC37U

97

96

1.7

Kafast

Kafast


1

PAUC37U

98

97

2

kAFAST

kAFAST


1

PAUC712L

106

104

0.5

kAFAST

kAFAST


1

PAUC712L

106

105

0.55

kAFAST

kAFAST


1

PAUC712L

103

101

0.65

kAFAST

kAFAST


1

PAUC712L

102

101

0.7

kAFAST

kAFAST


1

PAUC712L

101

100

0.8

kAFAST

kAFAST


1

PAUC712U

99

98

1.25

kAFAST

kAFAST


1

PAUC712U

100

99

1.3

kAFAST

kAFAST


1

PAUC712U

100

99

1.4

kAFAST

kAFAST


1

PAUC712U

98

95

1.7

kAFAST

kAFAST


1

PAUC712U

100

98

2

kAFAST

kAFAST




VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

@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...

 

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
jacksonan123
Lapis Lazuli | Level 10
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...

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

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.

snap.PNG

jacksonan123
Lapis Lazuli | Level 10
Yes this works, but I have a question.

When I input the data as a *.csv file for some reason it does not read
PAUC712U from block, it only reads PAUC712 which is the reason for it not
being in the legend. The value is a character so I tried to increase its
length via a format statement (i.e., format block $char20.).

It still did not read the entire PAUC71U. What type of format change do I
need?
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

format block $char20.

try format block $20.

jacksonan123
Lapis Lazuli | Level 10
That did not work. A recent reply suggested the same solution but did not
provide the code.
PGStats
Opal | Level 21

Works for me

 

SGPlot.png

 

your block variable might not be large enough and thus truncating the longest block names.

PG
Rick_SAS
SAS Super FREQ

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;

 

 

jacksonan123
Lapis Lazuli | Level 10
This is what I got:



OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

72

73 %put &=SYSVLONG4;

SYSVLONG4=9.04.01M5P09132017

74

75 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

88




jacksonan123
Lapis Lazuli | Level 10

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.

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

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: 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
  • 15 replies
  • 1834 views
  • 0 likes
  • 5 in conversation