BookmarkSubscribeRSS Feed
RamJ
Calcite | Level 5

The following program is printng all text and numbers in unbolded font. How can I have it print everything in bold. Also, the bars are printed on the top of the symbol. Can I have the symbol printed on the top of the bar? Also, is there a way to have a "blank" line inserted in-between certain bars? Here is the data and program I am using?

data x;
input sname $15. AGM LL UL ns2 na2;
format AGM LL UL f5.1;
datalines;
SCOT: Males 233.1 182.9 297.1 12 12
SCOT: Females 241.3 189.1 307.9 11 11
SCOT: NHW 218.4 170.8 279.4 10 10
SCOT: NHB 294.1 232.8 371.5 9 9
SCOT: HISP 217.9 167.0 284.3 8 8
SCOT: OTH 226.1 174.2 293.4 7 7
NNAL: Males 258.0 162.1 410.7 6 6
NNAL: Females 360.5 226.7 573.3 5 5
NNAL: NHW 334.9 214.9 522.0 4 4
NNAL: NHB 258.5 157.0 425.5 3 3
NNAL: HISP 324.1 202.9 517.8 2 2
NNAL: OTH 308.3 189.9 500.6 1 1
;
run;
title 'Adjusted Geometric Means with 95% Confidence Intervals';


proc sgplot data=x noautolegend nocycleattrs;
refline 150 600 / axis=x;
scatter y=ns2 x=agm / markerattrs=graphdata2
(symbol=circlefilled size=15 color=black);
highlow y=ns2 low=ll high=ul / type=bar intervalbarwidth=.05in
nooutline fillattrs=graphdata1 (color=Green);
yaxistable sname / y=ns2 position=left location=outside
nolabel valuejustify=left pad=(right=0px) labelattrs=(weight=bold);
yaxistable agm LL UL / y=nS2 position=right location=inside
labelhalign=center labelattrs=(weight=bold)
pad=(left=20px right=10px);
yaxis display=none offsetmin=0.1 offsetmax=0.05 values=(1 to 12) ;
run;

 

Ram Jain

3 REPLIES 3
hollandnumerics
Pyrite | Level 9

Ram,

 

Sometimes in life "size matters", but in ODS Graphics "order matters"!

 

The following code has been updated to:

  • split sname into 2 parts, so that your input statement reads the data you expect
  • reorder scatter after highlow, so the scatter is plotted after highlow (and on top of it!)
data x;
    length sname1 sname2 $7. sname $15.;
    input sname1 sname2 AGM LL UL ns2 na2;
    format AGM LL UL f5.1;
    sname = strip(sname1) || ' ' || strip(sname2);
    datalines;
SCOT: Males 233.1 182.9 297.1 12 12
SCOT: Females 241.3 189.1 307.9 11 11
SCOT: NHW 218.4 170.8 279.4 10 10
SCOT: NHB 294.1 232.8 371.5 9 9
SCOT: HISP 217.9 167.0 284.3 8 8
SCOT: OTH 226.1 174.2 293.4 7 7
NNAL: Males 258.0 162.1 410.7 6 6
NNAL: Females 360.5 226.7 573.3 5 5
NNAL: NHW 334.9 214.9 522.0 4 4
NNAL: NHB 258.5 157.0 425.5 3 3
NNAL: HISP 324.1 202.9 517.8 2 2
NNAL: OTH 308.3 189.9 500.6 1 1
;
run;

title 'Adjusted Geometric Means with 95% Confidence Intervals';

proc sgplot data=x noautolegend nocycleattrs;
    refline 150 600 / axis=x;
    highlow y=ns2 low=ll high=ul / type=bar intervalbarwidth=.05in
        nooutline fillattrs=graphdata1 (color=Green);
    scatter y=ns2 x=agm / markerattrs=graphdata2
        (symbol=circlefilled size=15 color=black);
    yaxistable sname / y=ns2 position=left location=outside
        nolabel valuejustify=left pad=(right=0px) labelattrs=(weight=bold);
    yaxistable agm LL UL / y=nS2 position=right location=inside
        labelhalign=center labelattrs=(weight=bold)
        pad=(left=20px right=10px);
    yaxis display=none offsetmin=0.1 offsetmax=0.05 values=(1 to 12);
run;

Enjoy!................Phil

 

PS. Look for "Philip R Holland" on Amazon - you may enjoy that too!  Smiley Wink

Philip R Holland
Holland Numerics: Blog and Forums
http://blog.hollandnumerics.org.uk
RamJ
Calcite | Level 5
Thank you so much but it still prints text on the Y-axis like SCOT: Males
and all numbers like 226.1 etc in unbolded font. Is there a way to print
these also in bold? Also, is there a way to insert blank lines, for
example, after SCOT: OTH.

##- Please type your reply above this line. Simple formatting, no
attachments. -##
hollandnumerics
Pyrite | Level 9

Ram,

 

A few amendments marked in red to match your specification:

 

data x;
    infile datalines truncover;
    length sname1 sname2 $7. sname $15.;
    input sname1 sname2 AGM LL UL ns2 na2;
    format AGM LL UL f5.1;
    if sname1 ne '-' then sname = strip(sname1) || ' ' || strip(sname2);
    datalines;
SCOT: Males 233.1 182.9 297.1 13 13
SCOT: Females 241.3 189.1 307.9 12 12
SCOT: NHW 218.4 170.8 279.4 11 11
SCOT: NHB 294.1 232.8 371.5 10 10
SCOT: HISP 217.9 167.0 284.3 9 9
SCOT: OTH 226.1 174.2 293.4 8 8
- - . . . 7 7
NNAL: Males 258.0 162.1 410.7 6 6
NNAL: Females 360.5 226.7 573.3 5 5
NNAL: NHW 334.9 214.9 522.0 4 4
NNAL: NHB 258.5 157.0 425.5 3 3
NNAL: HISP 324.1 202.9 517.8 2 2
NNAL: OTH 308.3 189.9 500.6 1 1
;
run;

options missing = ' ';

title 'Adjusted Geometric Means with 95% Confidence Intervals';

proc sgplot data=x noautolegend nocycleattrs;
    refline 150 600 / axis=x;
    highlow y=ns2 low=ll high=ul / type=bar intervalbarwidth=.05in
        nooutline fillattrs=graphdata1 (color=Green);
    scatter y=ns2 x=agm / markerattrs=graphdata2
        (symbol=circlefilled size=15 color=black);
    yaxistable sname / y=ns2 position=left location=outside
        nolabel valuejustify=left pad=(right=0px) labelattrs=(weight=bold)
        valueattrs = (weight=bold)
        ;
    yaxistable agm LL UL / y=nS2 position=right location=inside
        labelhalign=center labelattrs=(weight=bold)
        valueattrs = (weight=bold)
        pad=(left=20px right=10px);
    yaxis display=none offsetmin=0.1 offsetmax=0.05 values=(1 to 13);
run;

Does that work for you now?................Phil

 

PS. BTW you don't use na2 anywhere in this program!

Philip R Holland
Holland Numerics: Blog and Forums
http://blog.hollandnumerics.org.uk

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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