BookmarkSubscribeRSS Feed
Maider
Calcite | Level 5

I have a dataset with different observations and I want to plot those points in a 2D plot with the next code:

 

 

PROC GPLOT DATA=components_corr;
   PLOT Prin1*Prin2;
   SYMBOL1 VALUE=plus COLOR=blue POINTLABEL= ??; 
RUN;

 

But I dont know what to write in pointlabel in order to obtain a plot with different points and the number of observation of each point on it.

 

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

I think your best choice is to use the Statter Statement in PROC SGPLOT (Not GPLOT). 

 

Do a Google seach or check out the Graphically Speaking blog for examples.

ballardw
Super User

Here is a minimal example using the SASHELP.CLASS data set with Proc SGPLOT

proc sgplot data = sashelp.class;
   scatter x=height y=weight/datalabel=name;
run;

you can use any of the variables in the data set with DATALABEL option to provide a label for the points. I recommend not using ones with long text though.

 

If you have the observation number in the data use your variable name. If you don't , add it to the data prior to plotting possibly with something like

data toplot;
   set components.corr;
   obs=_n_;
run;

and use the toplot data set and datalabel=obs.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 6634 views
  • 1 like
  • 3 in conversation