Hi all,
Im trying to create a scatter plot with Sgpanel but I can`t figure how to customize it with my Costat variable.
Costat variable basicaly tells me if the company is Bankrupt(=1) or Not (=0). I would like to see the Non banrupt companies in green and the shape being circles where as the Bankrupt companies would be red stars.
Here is my actual code for now :
proc sgpanel data= analyse_all;
panelby H / rows= 1;
scatter X= X5 Y= X1;
run;
Here's some code that should do what you're asking (except I use a triangle instead of a star)...
%let name=sgpanel;
/*
Set your current-working-directory (to read/write files), if you need to ...
%let rc=%sysfunc(dlgcdir('c:\someplace\public_html'));
*/
filename odsout '.';
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" style=htmlblue;
ods graphics / imagemap tipmax=25000 imagefmt=png imagename="&name"
width=800px height=600px noborder;
libname my_data 'u:\web\proj\pabster';
data analyse_all; set my_data.data;
run;
/* user-defined format for text that prints in legend */
proc format;
value $status
"0" = "Not Bankrupt"
"1" = "Bankrupt"
;
run;
/* attribute map, for color & shape */
data myattrmap;
length id value markercolor markersymbol $20;
id='myid';
value='Not Bankrupt'; markersize=12; markercolor='green'; markersymbol='circle'; output;
value='Bankrupt'; markersize=12; markercolor='red'; markersymbol='triangle'; output;
run;
title1 h=16pt "Banking Graph";
proc sgpanel data=analyse_all dattrmap=myattrmap;
format costat $status.;
panelby H / rows= 1;
scatter X= X5 Y= X1 / group=costat attrid=myid;
keylegend / position=bottom fillheight=11pt noborder
title="" valueattrs=(color=gray33 size=11pt weight=bold);
run;
quit;
ODS HTML CLOSE;
ODS LISTING;
Try adding a GROUP = to your SCATTER statement to create different symbols. To customize the shapes you'll need to specify the attributes you want using the STYLEATTRS statement
GROUP= documentation reference
STYLEATTRS reference (datasymbols and datacolor)
@Pabster wrote:
Hi all,
Im trying to create a scatter plot with Sgpanel but I can`t figure how to customize it with my Costat variable.
Costat variable basicaly tells me if the company is Bankrupt(=1) or Not (=0). I would like to see the Non banrupt companies in green and the shape being circles where as the Bankrupt companies would be red stars.
Here is my actual code for now :proc sgpanel data= analyse_all; panelby H / rows= 1; scatter X= X5 Y= X1; run;
Here's some code that should do what you're asking (except I use a triangle instead of a star)...
%let name=sgpanel;
/*
Set your current-working-directory (to read/write files), if you need to ...
%let rc=%sysfunc(dlgcdir('c:\someplace\public_html'));
*/
filename odsout '.';
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" style=htmlblue;
ods graphics / imagemap tipmax=25000 imagefmt=png imagename="&name"
width=800px height=600px noborder;
libname my_data 'u:\web\proj\pabster';
data analyse_all; set my_data.data;
run;
/* user-defined format for text that prints in legend */
proc format;
value $status
"0" = "Not Bankrupt"
"1" = "Bankrupt"
;
run;
/* attribute map, for color & shape */
data myattrmap;
length id value markercolor markersymbol $20;
id='myid';
value='Not Bankrupt'; markersize=12; markercolor='green'; markersymbol='circle'; output;
value='Bankrupt'; markersize=12; markercolor='red'; markersymbol='triangle'; output;
run;
title1 h=16pt "Banking Graph";
proc sgpanel data=analyse_all dattrmap=myattrmap;
format costat $status.;
panelby H / rows= 1;
scatter X= X5 Y= X1 / group=costat attrid=myid;
keylegend / position=bottom fillheight=11pt noborder
title="" valueattrs=(color=gray33 size=11pt weight=bold);
run;
quit;
ODS HTML CLOSE;
ODS LISTING;
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.