BookmarkSubscribeRSS Feed
xxz3231
Calcite | Level 5

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!

9 REPLIES 9
Jay54
Meteorite | Level 14

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

xxz3231
Calcite | Level 5
Vector plot works very well,thank you Sanjay!
Rick_SAS
SAS Super FREQ

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.

xxz3231
Calcite | Level 5
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!
Jay54
Meteorite | Level 14

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.

Rick_SAS
SAS Super FREQ

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!

Rick_SAS
SAS Super FREQ

 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;
xxz3231
Calcite | Level 5
Thank you so much! That helps a lot! I have solved problem with band graph,thank you very much!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1894 views
  • 0 likes
  • 3 in conversation