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.

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 7956 views
  • 1 like
  • 3 in conversation