Used SGPLOT polygon but it gives not whole rectangle form.
Please post your code (and data, if you can) and explain what you are trying to accomplish.
If it helps, the coordinates for the POLYGON statement are in the data coordinate system. So if you want a rectangle that goes from 28% of the data range to 50% of the data range, you can use PROC MEANS to compute the min and max values of the coordinates, then use a DATA step to create the rectangle corners, which will have the values
XMin_Poly = XMin + 0.28*(XMax - XMin);
XMax_Poly = XMin + 0.5*(XMax - XMin);
The Y coordinates are computed similarly.
I too prefer using POLYGON plot in data coordinates as suggested by Rick. This is good if you want the figures to be represented in the legend, or be displayed in correct order. If this is not required, annotation is an alternative. In that case you can use SGAnnotation (or %SGANNO macros) in DataPercent drawspace.
I had the same thought as @Jay54 , because you can use DATAPERCENT as a drawing space. Here is a simple example:
data anno;
length function $ 9 drawspace $ 11 anchor $ 10;
function="rectangle";
drawspace="datapercent";
anchor="bottomleft";
x1=28;
y1=29;
width=22;
height=21;
output;
run;
proc sgplot data=sashelp.class sganno=anno;
scatter x=weight y=height;
run;
@Sagarg wrote:
Used SGPLOT polygon but it gives not whole rectangle form.
It is usually a good idea to include the code you attempted and describe what you need that the code isn't doing.
In the case of polygon the actual data step or file used is important.
An improperly shaped polygon would likely result from a missing vertex or an ID variable misaligned with the x and y coordinates.
Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.