Contributor
Posts: 21

# SAS 9.3 GRAPH QUESTION-POLYGON and Line Segment

Hello,everyone,

I want to draw a polygon simulated confidence interval.

My coordinates for (x1,y1) are over 2000,I know it's easy to do that in SAS 9.4 or R,however I only have SAS 9.3,I checked some references,it seems that in sas 9.3 annotation dataset  'POLYGON' (or 'POLYCONT')function only accept numbers input-once for a pair coordinates,is it possible to use variable here?

Moreover would you please give me some hints about how to draw line segment in SAS?

Thank you very much!

SAS Super FREQ
Posts: 1,227

## Re: SAS 9.3 GRAPH QUESTION-POLYGON and Line Segment

For line segments with SAS 9.3 SGPLOT, you can use either a Vector plot or a Series plot.

Contributor
Posts: 21

## Re: SAS 9.3 GRAPH QUESTION-POLYGON and Line Segment

Vector plot works very well,thank you Sanjay!
SAS Super FREQ
Posts: 3,908

## Re: SAS 9.3 GRAPH QUESTION-POLYGON and Line Segment

What statistic are you forming the confidene interval for? Why do you think you want to use a polygon?  More details, please!

For a continuous curve, use the BAND statement to display a confidence interval.

For a series of simulated Cis (such as for many simulated CIs for the mean), use the HIGHLOW statement to create a series of confidence intervals.

Contributor
Posts: 21

## Re: SAS 9.3 GRAPH QUESTION-POLYGON and Line Segment

Thank you so much for your quick reply,Rick! I am sorry I can't explain "Why you need it",for my professor asked me to use SAS to rewrite some R codes which are from former research projects-we need SAS output(but must including everything from R code).This is an example https://www.uvm.edu/~ngotelli/Rscripts/Confidence%20Interval%20Polygon.R
Can I do this in SAS?Thank you very much!
SAS Super FREQ
Posts: 1,227

## Re: SAS 9.3 GRAPH QUESTION-POLYGON and Line Segment

Consistency with R will be much easier with SAS 9.4.  For an academic institution, it should be easy to upgrade.  You could even use SAS University Edition, which is free, and provides all the SAS 9.4 features, including SGPLOT and GTL.

SAS Super FREQ
Posts: 3,908

## Re: SAS 9.3 GRAPH QUESTION-POLYGON and Line Segment

Yes. That plot is easily created by using the BAND statement.

If you are translating from R to SAS, you  should realize that not every program has a one-to-one mapping. Every language has conventions that make it unique. In particular, when you see the polygon() call in R, that does not necessarily mean that you should use the POLYGON statement in PROC SGPLOT.

PS: As a former professor myself, I predict that your professor would be thrilled to explain more about the plot and what it shows!  Professors love it when students ask questions!

SAS Super FREQ
Posts: 3,908

Here it is:

SAS Super FREQ
Posts: 3,908

## Re: SAS 9.3 GRAPH QUESTION-POLYGON and Line Segment

Here is the SAS program that generates the graph:

``````data CI;
call streaminit(12345);
do x = 1 to 100;
Exp = 50 + x*0.1;
ConHigh = Exp + 5 + rand("normal");
ConLow = Exp - 5 + rand("normal");
OneRun = Exp + rand("Normal",0,2);
output;
end;
run;

title "SGPLOT Reconstruction of R Graphic";
proc sgplot data=CI noautolegend;
band x=x lower=ConLow upper=ConHigh / fillattrs=(color=thistle);
series x=x y=Exp / lineattrs=(color="purple");
series x=x y=OneRun;
xaxis label="Time Step";
yaxis label="Population Size (N)";
run;
``````
Contributor
Posts: 21

## Re: SAS 9.3 GRAPH QUESTION-POLYGON and Line Segment

Thank you so much! That helps a lot! I have solved problem with band graph,thank you very much!
Discussion stats
• 9 replies
• 658 views
• 0 likes
• 3 in conversation