BookmarkSubscribeRSS Feed
Naveen1111
Calcite | Level 5

Hi Everyone, 

A month ago I have started sas, can anyone tell me why did we define xsys=2 ysys=2 and later xsys=7..any specific logic. Please help me and thanks in advance.

 

 /* Set the graphics environment */
goptions reset=all cback=white border htitle=12pt htext=10pt;  

data a;
   input Mid_Var $ Resp_Var;
   datalines;
AAA 5
AAA 4
AAA 7
BBB 7
BBB 6
BBB 9
CCC 4
CCC 3
CCC 6
DDD 5
DDD 4
DDD 7
;
run;

 /* Use PROC MEANS to calculate the statistics */
 /* needed to create the Annotate data set.    */
proc means mean std data=a noprint;
   by mid_var;
   output out=b mean=mean std=std;
run;

 /* Create the Annotate data set */
data anno;
   length color function $8;
   retain xsys ysys '2' hsys '4' when 'a' color 'depk' size 1;
   set b;

   /* Lower tick */
   function='move'; xsys='2'; ysys='2'; 
   midpoint=mid_var; y=mean-std; 
   output;
   function='draw'; 
   xsys='7'; ysys='2'; x=-2; y=mean-std;  
   output;
   function='draw'; xsys='7'; ysys='2'; 
   x=+4; y=mean-std;  
   output;

   /* Upper tick */
   function='move'; xsys='2'; ysys='2'; 
   midpoint=mid_var; y=mean+std; 
   output;
   function='draw'; xsys='7'; ysys='2'; 
   x=-2; y=mean+std;  
   output;
   function='draw'; xsys='7'; ysys='2'; 
   x=+4; y=mean+std;  
   output;

   /* Join upper and lower */
   function='move'; xsys='2'; ysys='2'; 
   midpoint=mid_var; y=mean-std;  
   output;
   function='draw'; xsys='2'; ysys='2'; 
   midpoint=mid_var; y=mean+std;  
   output;
run;

axis1 order=(0 to 10 by 5)
      label=(angle=90 h=11pt 'Response Variable'); 
axis2 label=(h=11pt 'Midpoint Variable');   

title1 'One Std of the Mean';

 /* Create the graph using the ANNO= option */
 /* on the VBAR statement.                  */
proc gchart data=a;
   vbar mid_var / anno=anno raxis=axis1 maxis=axis2 
                  type=mean sumvar=resp_var
	          width=10 space=4; 
run;
quit;

 

5 REPLIES 5
PaigeMiller
Diamond | Level 26

It means you are using actual data values to determine where items go on a plot.

 

See the documentation at: https://documentation.sas.com/?docsetId=graphref&docsetTarget=annotate_xsys.htm&docsetVersion=9.4&lo...

--
Paige Miller
Naveen1111
Calcite | Level 5
Why did we use xsys=7 ...instead of 7 i tried with 6 but not getting the same output. There must b some logic. Also advise me things which we must keep in our mind while creating graph.
PaigeMiller
Diamond | Level 26

The documentation explains what XSYS=7 means. I don't know why it was chosen in your program, and certainly different choices may result in no difference on the graph for some data and some graphs.

--
Paige Miller
ballardw
Super User

@Naveen1111 wrote:
Why did we use xsys=7 ...instead of 7 i tried with 6 but not getting the same output. There must b some logic. Also advise me things which we must keep in our mind while creating graph.

First is what is the graph supposed to do. Second know the tools. Gchart is old and supports a small number of chart types. Sgplot, and Sgpanel, support around 29 types of plots (counting variations of HBAR/VBAR and HBOX/VBOX and similar as one type).

Since I see comments about upper and lower tick I would guess that you are connecting to points in a vertical line.

 

Which might mean that it is time to investigate Proc SGPLOT with a HGHLOW graph statement.

One of the very big improvements with the newer procedures is the ability to overlay different graphs (within limitations).

You would use a VBARBASIC to do the bars and a HIGHLOW with variables in a single data set.

 

Or if the values are supposed to be error bars on the bar graph then perhaps you would use a simple VBAR with the LIMITS=BOTH option which can calculate error bars. And the option LIMITSTAT= could calculate error bars for Confidence limits, standard deviation or standard error when using STAT=Mean.

FreelanceReinh
Jade | Level 19

Hi @Naveen1111 and welcome to the SAS Support Communities!

 

Here's a PROC SGPLOT step using several options to make the created plot virtually identical to the bar chart you created with PROC GCHART (but possibly fewer options would be okay for your purposes):

ods graphics on / border=off;
title 'One Std of the Mean';

proc sgplot data=a noautolegend;
vbar mid_var / response=resp_var stat=mean limitstat=stddev barwidth=0.7               
               fillattrs=(color='CX7C95CA') limitattrs=(color='depk');
xaxis label='Midpoint Variable' display=(noticks);
yaxis label='Response Variable' values=(0 to 10 by 5) minor minorcount=9;
run;

With that you don't need

  • a SAS/GRAPH license
  • to calculate descriptive statistics in a separate PROC MEANS step
  • to create an annotation dataset in a separate DATA step
  • to think about different coordinate systems (XSYS, YSYS).

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 709 views
  • 2 likes
  • 4 in conversation