The SAS Output Delivery System and reporting techniques

Non breaking spaces and formatting for gaps on an axis

Reply
Frequent Contributor
Posts: 81

Non breaking spaces and formatting for gaps on an axis

Ive had some inconsistency in applying formatting to the internal, values within a categorical variable that I want to place on an x axis in proc sgplot.

Previous we were discussing how to create non breaking spaces as suggested by :

https://blogs.sas.com/content/graphicallyspeaking/2017/10/16/tips-tricks-multiple-blank-categories-a...

 

I must be doing something wrong in my formatting as every approach I have tried does not implement the required new formats consistently, and we are no getting blank non breaking spaces.

 

My code and datasets were previously shared and would be happy to share again,

 

Thanks,

 

Christos 

Super User
Posts: 13,508

Re: Non breaking spaces and formatting for gaps on an axis

Posted in reply to ChristosK

Data in the form of data steps, code attempted and very explicit descriptions of what is not quite working is helpful.

 

Also the exact SAS release you are using may be needed as many options have been added to the SG procedures with each release.

Frequent Contributor
Posts: 81

Re: Non breaking spaces and formatting for gaps on an axis

Thanks.

I'm working with SAS Studio University Edition, and it is up to date:

First problem is with Formatting:

proc format;
value $Namefmt
"Age" ="Age"
"BMI" ="BMI"
"Sex_num" ="Sex (Male)"
"CABG_i" ="CABG isolated"
"Valve_i" ="Valve isolated"
"CABG_V" ="CABG / Valve"
"OHT" ="Heart Transplant"
"Redo1" ="Redo"
"IABP_ever1" ="Hx of IABP"
"Hyperlip" ="Hyperlipidemia"
"NIDDM1" ="NIDDM"
"COPD" ="COPD"
"CHF" ="CHF"
"Afib" ="Afib"
"CM" ="Cardiomyopathy"
"CAD" ="CAD"
"MI" ="Hx of MI"
"AICD" ="AICD"
"CRF" ="Renal Failure"
"PVD" ="PVD"
"ASA" ="Aspirin"
"BB" ="Beta Blockers"
"Steroids" ="Steroids"
"Amio" ="Amiodarone"
"LMWH" ="LMWH"
"Digoxin" ="Digoxin"
"AA1" ="Alpha Antagonists"
"Statin1" ="Statins"
"Nitrates1" ="Nitrates "
"Diurectics1" ="Diuretics"
"pre_Na" ="preop Na"
"pre_BUN" ="preop BUN"
"pre_Cr" ="preop Cr"
"pre_Gluc" ="preop Gluc"
"pre_Neutro" ="preop Neutrophils"
"pre_Lymph" ="preop Lymphocytes"
"pre_Hgb" ="preop Hb"
"pRBC" ="PRBC"
"FFP" ="FFP"
"PLT" ="Platelets"
"Cryo" ="Cryoprecipitate"
"CPBmin" ="Bypass time"
"AoXCmin" ="Cross Clamp time"
"Ind_Temp1" ="induction Temp(C)"
"Ind_HR1" ="ind HR"
"Ind_SBP1" ="ind SBP"
"Ind_MAP1" ="ind MAP"
"Ind_DBP1" ="ind DBP"
"Ind_PAS1" ="ind PAS"
"Ind_mPAP1" ="ind mPAP"
"Ind_PAD1" ="ind PAD"
"pulse_p" ="ind pulse pressure"
"A" ="."
"B" ="."
"C" =".";
run;

data new;
set HEERDT.VP_Table2b2;
format Name $Namefmt.;
run;

I crated the missing values for A,B,C  so they would come out as empty lines in the subsequent tables.

I also tried this with a data step to see whether it made any difference. The "Induction BP's" did not get formatted consistently. Some were continuous words, and some had a space after "Ind".

 

This was the code before attempting the formatted approach:

proc template;
define style mystyle;
parent=styles.sasweb;
class graphwalls /
frameborder=off;
class graphbackground /
color=white;
end;
run;

ods listing close;
ods html style=mystyle path='.' file='newgraph.html';
ods graphics / reset=all border=off width=800 height=900;


/* sd OR's */
/* alternate colorbands */

proc sgplot data =HEERDT.VP_Table2b2 nowall noborder ;
Title "OR (95% CI) for covariates across Vasoplegia Severity" ;
styleattrs datacontrastcolors=(CX18577A CX30CC6E ) ;
scatter x=sdOR y=Name / xerrorupper=sdUCL xerrorlower=sdLCL noerrorcaps markerattrs=(symbol=circlefilled size =5 )
group=Severity groupdisplay=cluster clusterwidth=0.6;
yaxis DISCRETEORDER= DATA reverse ;
xaxis display =(noticks nolabel noline) VALUEATTRS=(Color=Black Family=Arial Size=8 Style=Normal Weight=Normal)type =log logbase =10;
yaxis display =(noticks nolabel noline) VALUEATTRS=(Color=Black Family=Arial Size=8 Style=Normal Weight=Normal)
valueshalign=left colorbands=odd colorbandsattrs=(transparency=0.7);
refline 1.0 / axis=x discretethickness=1 lineattrs=(color=cxd0e0f0);

yaxistable pdp2_char sdORCI /class =Severity classdisplay =stack position=right location=outside
VALUEATTRS=(Color=Black Family=Arial Size=8 Weight=Normal ) VALUEHALIGN=CENTER VALUEJUSTIFY= CENTER CLASSORDER=DATA
COLORGROUP=Severity;
xaxis display=(nolabel) values=(0.4 1.0 1.5 2.0 2.5 5 );
run;

 I added this in my first attempt:

 

proc sgplot data =HEERDT.VP_Table2b2  nowall noborder ;
Title "OR (95% CI) across Vasoplegia Severity, units=1 s.d." ;
styleattrs datacontrastcolors=(CX18577A CX30CC6E ) ;
format Name $Namefmt.;

.......(rest is the same as above).

 

Then I tried this valuesformat approach:

proc sgplot data =Heerdt.Vasoplegia_space  nowall noborder ;
Title "OR (95% CI) for covariates across Vasoplegia Severity" ;
styleattrs datacontrastcolors=(CX18577A CX30CC6E ) ;
scatter x=sdOR y=Name / xerrorupper=sdUCL xerrorlower=sdLCL noerrorcaps markerattrs=(symbol=circlefilled size =5 )
group=Severity groupdisplay=cluster clusterwidth=0.6;
yaxis DISCRETEORDER= DATA reverse valuesformat= $Namefmt.;

(the rest being the same)

 

I do get the spaces, but the formatting steps do not result in an empty value on the y axis for "A,B, and C". Those letters do appear on the y axis, and there is an empty space across that level. So its frustrating that these letters are still there, and that the formatted values on that Y axis do not appear as requested.

 

The only difference  from the examples that Sanjay gave us were that these non breaking spaces had only one measure at that categorical axis. My values have two because im comparing OR's actoss two levels of severity of an outcome. Might just be that we cant do this in this locked down version of SAS.

Sanjay Kindly agreed to look at my data and the code, so it will be interesting to see his solution.

 

Much appreciated, Christos 

 

 

SAS Super FREQ
Posts: 9,365

Re: Non breaking spaces and formatting for gaps on an axis

Posted in reply to ChristosK
Hi:
Sanjay and the other Graph folks typically answer questions posted in the SAS/Graph and ODS Graphics forum: https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/bd-p/sas_graph ... so you might get more responses if you posted over there.

cynthia
Ask a Question
Discussion stats
  • 3 replies
  • 177 views
  • 1 like
  • 3 in conversation