Reputation: 1764
I have two questions concerning SGPlot in SAS. I have a large dataset, and am trying to create a scatterplot which highlights differences between brands of similar prooduct. I am able to get different colors for each brand, but for some reason the symbols will not show up. I had to close ods listing and html because I was getting an error ERROR: Cannot write image to filename.png. Please ensure that proper disk permissions are set. I'm not sure this can be fixed. Is there another way to get the symbols?
Also, I have a 95% prediction ellipse, but am wondering if there is a way to have an ellipse for each brand. Thanks.
data example;
length product brand $20;
input product $ brand $ item price trans;
cards;
sconces AllenRoth 1 1.5 300
sconces AllenRoth 2 2.75 350
sconces AllenRoth 3 1.75 300
sconces AllenRoth 4 0.75 400
sconces GardenTreasures 1 3 200
sconces GardenTreasures 2 3.25 175
sconces GardenTreasures 3 2.75 100
sconces GardenTreasures 4 3.5 100
sconces GardenTreasures 5 4 150
sconces OtherBrand 1 0.5 850
sconces OtherBrand 2 0.45 875
sconces OtherBrand 3 0.75 900
sconces OtherBrand 4 1 650
sconces OtherBrand 5 0.75 700
sconces BrandX 1 1 200
sconces BrandX 2 1.25 500
sconces BrandX 3 1.2 400
sconces BrandX 4 0.95 375
sconces BrandX 5 1 300
sconces BrandX 6 1 200
sconces BrandX 7 1.35 400
sconces BrandX 8 1.5 350
curtains AllenRoth 1 10 200
curtains AllenRoth 2 12 250
curtains AllenRoth 3 11.5 200
curtains AllenRoth 4 10 400
curtains AllenRoth 5 17 500
curtains AllenRoth 6 15 100
curtains AllenRoth 7 29 50
curtains AllenRoth 8 50 12
curtains GardenTreasures 1 80 150
curtains GardenTreasures 2 60 75
curtains GardenTreasures 3 100 50
curtains BrandX 1 9 300
curtains BrandX 2 12 350
curtains BrandX 3 10 275
curtains BrandX 4 7.5 400
curtains BrandX 5 12 200
curtains BrandX 6 8.5 500
;
run;
proc format;
value legfmt
1 = 'legend value 1'
2 = 'legend value 2'
3 = 'legend value 3'
4 = 'legend value 4';
run;
proc sort data= example;
by product brand;
run;
ods listing close;
ods html close;
proc sgplot data= example ;
title1 "plotting trans by price";
footnote1 "final";
by product;
scatter x= trans y= price / datalabel= item group= brand name= "scp";
ellipse x=trans y=price;
xaxis label= "Number of Transactions";
yaxis label= "Average Selling Price";
keylegend "scp" / noborder across= 1 down= 4 location= outside position= topright
title= "Legend";
run;
ods graphics off;
ods listing close;
Upvotes: 1
Views: 1583
Reputation: 63424
Likely your gpath is not set properly. This works for me, for example:
ods html path='c:\temp' file='test.html' gpath='c:\temp\' style=htmlblue;
proc sgplot data= example ;
title1 "plotting trans by price";
footnote1 "final";
by product;
scatter x= trans y= price / datalabel= item group= brand name= "scp";
ellipse x=trans y=price;
xaxis label= "Number of Transactions";
yaxis label= "Average Selling Price";
keylegend "scp" / noborder across= 1 down= 4 location= outside position= topright
title= "Legend";
run;
ods html close;
If you don't set gpath
to a path you can write to, it may be set to something that you don't have write access to, especially if you have a server installation. PATH and GPATH can be set to the same or different paths.
I don't believe you can have an ellipse for each brand, largely because it would look terrible. Having four prediction ellipses, even with different colors, would be very difficult to visually distinguish. A different chart type may be appropriate if you are trying to show that (perhaps a bar graph for example with brand
as the bar type and selling price buckets as a group variable).
Upvotes: 1