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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 697 views
  • 1 like
  • 2 in conversation