BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Turtle
Obsidian | Level 7

Hi,

(sorry if I post this in diff location)

 

Now, I'm making a line graph using SAS Studio from OnDemand for Academics, and having problem regarding its legend.

This is what I'm saying strange.

 

strange value.png

There's three squares (which appears in diff symbols I chose in rtf) and one sharp symbol, which I've never seen before.

I've made 10 graphs of this kind so far, and I haven't got this problem.  

Here is the code I used. (no error or warning when I run this)

proc sgplot data=final.g10 noautolegend;
	title "G.「いい天気『(だ)ね』」10代の結果" font="MS Mincho";
	styleattrs datasymbols=(SquareFilled DiamondFilled TriangleFilled Square Diamond Triangle);
	series x=地区 y=使用度 /group=変化形 break  markers;
	xaxis grid label="地区" labelattrs=(family="MS Mincho" size=12pt);
	yaxis values=(0 to 2 by 0.5) grid label="使用度" labelattrs=(family="MS Mincho" size=12pt);
	keylegend / position=bottom location=outside across=1 titleattrs=(family="MS Mincho" size=12pt) valueattrs=(family="MS Mincho" size=12pt);
	ods graphics on / width=6in;
	ods graphics on / height=7in;

run;

At first, I thought maybe this is because writing more than three symbols to use even the dataset have three values,

but nothing changed and the strange one was still there.

 

Can anyone figure out what's happening here and why this happens, and how can I make it not appear?

 

Thanks in advance for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

Do you have missing group data in your code?  You are likely getting that.  You can set NOMISSINGGROUP in the SERIES plot to ignore missing values.

View solution in original post

7 REPLIES 7
WarrenKuhfeld
Rhodochrosite | Level 12

I do not see any reason for you to get that legend with the code you provide.  Are you sure that code made that legend?

 

I would specify tmplout='file' in the proc statement, then look at the file, which will show the GTL.  That might give you a clue.

 

I assume that since you specify styleattrs, that you want to see those markers.  If so, then add attrpriority=none to your ODS Graphics statement.

Turtle
Obsidian | Level 7

Thanks for the reply.

 

Yes, that's what I used to get the legend, and I haven't got that kind of legend so far even though I used the same code (of course I changed title and other options in those cases) so far making same kind of graph.

After I post the first post, I tried it again, and then with the different dataset, however in both cases, there were the strange symbol in the legend...

 

I added tmplout='file' in the proc statement like this,

proc sgplot data=final.g10 noautolegend tmplout='file';
	title "G.「いい天気『(だ)ね』」10代の結果" font="MS Mincho";

(after this is the same as the one I wrote in the first post)

and I got a file named "file", but it doesn't have any filename extension like .doc or .html etc..

I'm not sure if I'm doing right or not... you mentioned that I can get the GTL, but it seems I couldn't?

Could you please point out what was wrong in this code, which I couldn't get the GTL?

 

Thanks,

WarrenKuhfeld
Rhodochrosite | Level 12

That should make a file called 'file' in your current working directory that should contain the GTL.  I would want to see exactly what goes into the legend.

Turtle
Obsidian | Level 7

Thanks for the reply.

Yes, it create a file named "file" and when I opened it in SAS Studio as text file, here's what it shows.

proc template;
define statgraph sgplot;
begingraph / collation=binary dataSymbols=( SQUAREFILLED DIAMONDFILLED TRIANGLEFILLED SQUARE DIAMOND TRIANGLE );
EntryTitle "G.「いい天気『(だ)ね』」10代の結果" /;
layout overlay / xaxisopts=( Label="地区" LabelAttrs=( Size=12pt Family="MS Mincho") type=discrete discreteopts=( TickValueFitPolicy=SplitRotate ) griddisplay=on ) y2axisopts=(labelFitPolicy=Split) yaxisopts=( Label="使用度" labelFitPolicy=Split LabelAttrs=( Size=12pt Family="MS Mincho") type=linear linearopts=( tickvaluelist=( 0 0.5 1 1.5 2 ) viewmin=0 viewmax=2 ) griddisplay=on ) y2axisopts=(labelFitPolicy=Split);
SeriesPlot X='地区'n Y='使用度'n / primary=true break=true Group='変化形'n display=(markers) LegendLabel="使用度" NAME="SERIES";
DiscreteLegend "SERIES" / Location=Outside across=1 valign=bottom Title="変化形" TitleAttrs=( Size=12pt Family="MS Mincho") ValueAttrs=( Size=12pt Family="MS Mincho");
endlayout;
endgraph;
end;
run;

Is there anything to point out which could be the cause of the strange symbol?

 

Thanks,

Jay54
Meteorite | Level 14

Do you have missing group data in your code?  You are likely getting that.  You can set NOMISSINGGROUP in the SERIES plot to ignore missing values.

Turtle
Obsidian | Level 7

Thank you for the reply.

As a result, NOMISSINGGROUP worked!!

 

I wonder why this started to appear since as I already mentioned, I've never seen this strange value... even though I used the almost same code and dataset...

 

Anyway, I really appreciate your reply which worked as my best solution!!

Thanks a lot!

 

Thanks,

 

Jay54
Meteorite | Level 14

You are welcome.  It depends on the data.  If your data has missing values in the group variable, these are represented using the special symbol.  These markers are also likely in the graph itself, unless associated (x, y) values are missing. Often, missing values are generated when merging data sets.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 1467 views
  • 4 likes
  • 3 in conversation