BookmarkSubscribeRSS Feed
braam
Quartz | Level 8

Dear All,

 

I would like to draw vlines with mean and standard deviation, instead of standard errors. The below code gives me the vline with StdErr. Could anybody help me with this?

Thanks in advance!

 


* Plot ;
	data temp;
		set sashelp.cars;

		if origin in ("Asia" , "Europe") then group= 1;
		else group= 2;

		if type= "Hybrid" then delete;
		run;



	proc sgplot data= temp;
		vline Type / 
			response= EngineSize 
			stat= mean 
			markers
			limitstat= stderr
			group= group;
			;
		run;


* Summary Stat ;
	proc sort data= temp; by type group ;
		run;

	proc means data= temp n sum mean std;
		class type group ;
		var EngineSize;
		run;
1 REPLY 1
ballardw
Super User

When you want to use an "error" different than is supplied directly by a plot option then you need to calculate the value yourself, placing the upper and/or lower value into a different variable and use an option that allows specifying limit variables, which may mean a different type of plot.

 

data work.temp;
   set sashelp.cars;

   if origin in ("Asia" , "Europe") then group= 1;
   else group= 2;

   if type= "Hybrid" then delete;
run;

proc summary data=work.temp nway;
   class type group;
   var enginesize;
   output out=work.summary
      mean= std= /autoname;
run;

data work.plot;
   set work.summary; 
   es_upper = enginesize_mean+ enginesize_stddev;
   es_lower = enginesize_mean- enginesize_stddev;
run;

proc sgplot data=work.plot ;
   series x=type y=enginesize_mean/group=group;
   scatter x=type y=enginesize_mean/group=group
          yerrorupper=es_upper
          yerrorlower=es_lower
   ;
run;

SAS Innovate 2025: Register Now

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 974 views
  • 1 like
  • 2 in conversation