BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bconner
Fluorite | Level 6

Hi,

 

I am trying to reproduce a vbar graph in SAS that was done in C#.  It has a 7.25" horizontal axis with 1 1/4" padding on the left and right.

I'm able to get everything dialed in but the padding.  I'm assuming that would be on the axis statement with the maxis= parameter on the vbar statement.  Can someone point me in the right direction?

 

This is what I'm looking for.  Thanks!

 

--Ben

 

vbar snippetvbar snippet

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Add your OFFSET to AXIS3 (your gaxis), not AXIS1 (your midpoint axis). That should give you what you want.

View solution in original post

8 REPLIES 8
ballardw
Super User

Example data and the code you are using so far will prevent us from having to pull details one a time.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

Note that your statement about "axis statement" and "maxis" almost certain means that you are using device based graphics such as GCHART. It may be time to start using the newer procedures such as SGPLOT or the Graphics Template Language where SAS is actively adding more functionality.

bconner
Fluorite | Level 6

Good points.  Learning the newer stuff is on my list.  This sample can be run with the code below.

Thanks!

 

--Ben

 

 

data test;

input order ct pct;

format order order. ct st.;

cards;

0 2 66.7

0 1 67.4

1 2 0.0

1 1 26.3

2 2 100.0

2 1 100.0

;;;

 

 

proc format; value st 2='Wholesale' 1='Retail'; value order 0='Statewide' 1='Regional' 2='National'; run;

 

ods region y=3.2in x=.5in width=7.5in height=3in;

pattern2 value=solid color=darkblue;

pattern2 value=solid color=cyan;

pattern3 value=solid color=blue;

 

legend1 position=(top) across=3 label=none ;

 

axis1 label=none value=none offset=(.5in,.5in) width=2;

axis2 label=none width=2;

axis3 label=none;

 

proc gchart data=test;

vbar order / type=sum sumvar=pct autoref clipref discrete noframe group=ct subgroup=order

width=14

gspace=8

space=0

legend=legend1

outside=sum

frame

maxis=axis1

raxis=axis2

gaxis=axis3;

run;

quit;

 

DanH_sas
SAS Super FREQ

Add your OFFSET to AXIS3 (your gaxis), not AXIS1 (your midpoint axis). That should give you what you want.

bconner
Fluorite | Level 6

Hi Dan,

 

Thank you so much!  Just didn't see it.  I don't use graph nearly as much as I used to. 

 

--Ben

ballardw
Super User

This may get you started:

ods graphics /width=7.5in height=3in;

proc sgplot data=test ;
   styleattrs datacolors=(darkblue cyan blue)
;
   vbar ct /response=pct group=order
              groupdisplay=cluster clusterwidth=.7
   ;
   /* offsetmax and min are PROPOTIONS of the axis width
      not absolute measures the OFFSET and the CLUSTERWIDTH
      can interact as both are using proportions of axis width
   */
   xaxis offsetmin=.3 offsetmax=.3;
run;

You will need to refer to the documentation for the options as XAXIS and YAXIS statements are quite different than AXIS statements as far as options.

KEYLEGEND controls appearance of the legend

 

There are actually 3 different VBAR statements: VBAR VBARPARM and VBARBASIC. The VBARPARM is likely better with summary data. VBARBASIC would be used if you want to overlay other data such as a scatter, series or box plot on the same chart. (Told you there were more things you could do with SGPLOT than GCHART)

 

The colors will be based on the current active style unless overridden such as with the STYLEATTRS statement for the data colors. Similar overrides are available for markers and lines. Consult the documentation.

 

If you use the same color/line/marker/fill patterns frequently you might also consider creating DATTRMAP, for discrete data values, or RATTRMAP datasets that can consistently apply the same rules for similar values.

bconner
Fluorite | Level 6

Wow.  You weren't kidding.  When I'm done with this I better start looking at the sg* graph proc families.

Some days I feel so old...  (then, I did start with vsn 5.13).

 

Thanks much!

 

--Ben

ballardw
Super User

@bconner wrote:

Wow.  You weren't kidding.  When I'm done with this I better start looking at the sg* graph proc families.

Some days I feel so old...  (then, I did start with vsn 5.13).

 

Thanks much!

 

--Ben


After you get a feel for the SGPLOT and SGPANEL then you end up in GTL (Graphics Template Language) and Proc SGRENDER that lets you create such single images as found on this page:

http://support.sas.com/kb/35/177.html

go to the results tab

Or just scan through the images on http://support.sas.com/sassamples/graphgallery/PROC_SGRENDER.html

 

DanH_sas
SAS Super FREQ

Assuming you are using PROC SGPLOT do create this output, use the OFFSETMIN and OFFSETMAX options on the XAXIS statement to move these bar clusters further in from the end of the axes.

 

Hope this helps!

Dan

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!

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
  • 8 replies
  • 2160 views
  • 2 likes
  • 3 in conversation