Proc Report in SAS ODS WORD file is removing borders - sas

In my SAS Code, I am trying to Report a table into a Word file using SAS ODS statement. And I am using the Company's standard styles. When the job runs, I can see the borders of Proc report output table in the output window. But these are gone in the Word file. Please see code below:
ods word file="&outfolder\Tabulations and graphs for &current_month. &current_year. report.docx" style=custom_style;
options orientation=landscape nodate nonumber center topmargin=0.1in bottommargin=0.15in rightmargin=0.2in leftmargin=0.2in papersize=letter;
ods escapechar="^";
ods graphics on/ outputfmt=png height = 6.75in;
%let footnote_style = ^S = {just=l font_size=7pt font_weight = light};
proc report data=out.sample nowd spanrows split="$" ;
/*There are multiple define statements here*/
run;
ods word close;
There is a long list of customized styles, So I can't remove it.
Also, If I use ODS PDF then the borders appear in PDF but somehownot in docx file.
Custom Style code:
proc template;
define style Styles.custom_styles;
style fonts/
'TitleFont2'=("Arial",12pt,bold)
'TitleFont'=("Arial",12pt,bold)
'headingFont'=("Arial",10pt,bold)
'docFont'=("Arial",10pt)
'footFont'=("Arial",8pt)
'StrongFont'=("Arial",14pt,bold)
'EmphasisFont'=("Arial",14pt,italic)
'FixedEmphasisFont'=("<monospace>, Courier, monospace",10pt,italic)
'FixedStrongFont'=("<monospace>, Courier, monospace",10pt,bold)
'FixedHeadingFont'=("<monospace>, Courier, monospace",10pt)
'BatchFixedFont'=("<monospace>, Courier, monospace",10pt)
'FixedFont'=("<monospace>, Courier, monospace",10pt)
'headingEmphasisFont'=("Arial",14pt,bold italic);
style GraphFonts/
'GraphDataFont'=("Arial",7pt)
'GraphValueFont'=("Arial",9pt)
'GraphLabel2Font'=("Arial",10pt)
'GraphLabelFont'=("Arial",10pt)
'GraphFootnoteFont'=("Arial",8pt)
'GraphTitleFont'=("Arial",12pt,bold)
'GraphTitle1Font'=("Arial",12pt,bold)
'GraphAnnoFont'=("Arial",8pt)
'GraphUnicodeFont'=("<MTsans-serif-unicode>",9pt);
style color_list "Colors used in the default style"/
'bgA'=cxffffff
'bgA1'=cx005293
'bgb1'=cxe05206
'fgA'=cxffffff
'fgB1'=cx000000
'grey'=cxCCCCCC
'fgD1'=cx005293
'blue1'=cx005293
'orange1'=cxe05206
'red1'=cxd52b1e
'green2'=cx007582
'grey2'=cx6f7c7d
'moss2'=cx476822
'yellow2'=cxf6a800
'black2'=cx31261d
'blue2'=cx009cde
'black'=cx000000;
style colors "Abstract colors used in the default style"/
'headerfg'=color_list('bgA')
'headerbg'=color_list('bgA1')
'tablebg'=cxcccccc
'headerfgemph'=color_list('bgA')
'headerbgemph'=color_list('bgA1')
'headerfgstrong'=color_list('bgA')
'headerbgstrong'=color_list('bgA1')
'datafgemph'=color_list('fgB1')
'databgemph'=color_list('bgA')
'datafgstrong'=color_list('fgB1')
'databgstrong'=color_list('bgA')
'datafg'=color_list('fgB1')
'databg'=color_list('bgA')
'batchfg'=color_list('blue1')
'batchbg'=color_list('bgA')
'tableborder'=color_list('fgD1')
'notefg'=color_list('fgB1')
'notebg'=color_list('bgA')
'bylinefg'=color_list('blue1')
'bylinebg'=color_list('bgA')
'captionfg'=color_list('fgB1')
'captionbg'=color_list('bgA')
'proctitlefg'=color_list('fgB1')
'proctitlebg'=color_list('bgA')
'titlefg'=color_list('fgB1')
'titlebg'=color_list('bgA')
'systitlefg'=color_list('fgB1')
'systitlebg'=color_list('bgA')
'contentfg'=color_list('fgB1')
'contentbg'=color_list('bgA')
'docfg'=color_list('fgB1')
'docbg'=color_list('bgA');
style graphcolors/
'gdata1'=color_list('blue1') 'gcdata1'=color_list('blue1')
'gdata2'=color_list('orange1') 'gcdata2'=color_list('orange1')
'gdata3'=color_list('red1') 'gcdata3'=color_list('red1')
'gdata4'=color_list('green2') 'gcdata4'=color_list('green2')
'gdata5'=color_list('grey2') 'gcdata5'=color_list('grey2')
'gdata6'=color_list('moss2') 'gcdata6'=color_list('moss2')
'gdata7'=color_list('yellow2') 'gcdata7'=color_list('yellow2')
'gdata8'=color_list('black2') 'gcdata8'=color_list('black2')
'gdata9'=color_list('blue2') 'gcdata9'=color_list('blue2')
'gcdata12'=cxF7AC4E 'gdata12'=cxF7AC4E
'gcdata11'=cxB38EF3 'gdata11'=cxB38EF3
'gcdata10'=cx47A82A 'gdata10'=cx47A82A
'gcmiss'=cx979797
'gmiss'=cxc3c3c2
'gablock'=colors('docbg')
'gblock'=colors('docbg')
'gcclipping'=cxDC531F
'gclipping'=cxE7774F
'gcstars'=cx000000
'gstars'=cxB9CFE7
'gcruntest'=cxBF4D4D
'gruntest'=cxCAE3FF
'gccontrollim'=cxBFC7D9
'gcontrollim'=cxE6F2FF
'gcerror'=cx000000
'gerror'=cxB9CFE7
'gcpredictlim'=cx003178
'gpredictlim'=cxB9CFE7
'gcpredict'=cx003178
'gpredict'=cx003178
'gcconfidence2'=cx003178
'gcconfidence'=cx003178
'gconfidence2'=cxB9CFE7
'gconfidence'=cxB9CFE7
'gcfit2'=cx003178
'gcfit'=cx003178
'gfit2'=cx003178
'gfit'=cx003178
'gcoutlier'=cx000000
'goutlier'=cxB9CFE7
'gcdata'=cx000000
'gdata'=cxB9CFE7
'ginsetheader'=colors('docbg')
'ginset'=cxFFFFFF
'greferencelines'=cx808080
'gheader'=colors('docbg')
'gconramp3cend'=cxFF0000
'gconramp3cneutral'=cxFF00FF
'gconramp3cstart'=cx0000FF
'gramp3cend'=cxDD6475
'gramp3cneutral'=cxFFFFFF
'gramp3cstart'=cx967CD0
'gconramp2cend'=cx99CCFF
'gconramp2cstart'=cxFFFFFF
'gramp2cend'=cx967CD0
'gramp2cstart'=cxFFFFFF
'gtext'=color_list('black')
'glabel'=color_list('black')
'gborderlines'=color_list('black')
'goutlines'=color_list('black')
'ggrid'=cxECECEC
'gaxis'=color_list('grey')
'gshadow'=cx000000
'glegend'=cxFFFFFF
'gfloor'=cxFFFFFF
'gwalls'=cxFFFFFF;
style StartUpFunction "Controls the StartUp Function. TAGATTR is only element used.";
style ShutDownFunction "Controls the Shut-Down Function. TAGATTR is only element used.";
style Container "Abstract. Controls all container oriented elements." /
font=Fonts('DocFont')
color=colors('docfg')
backgroundcolor=colors('docbg');
style Index from Container "Abstract. Controls Contents and Pages." /
color=colors('contentfg')
backgroundcolor=colors('contentbg');
style Document from Container "Abstract. Controls the various document bodies." /
doctype="<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 3.2 Final//EN"">"
contenttype="text/html"
protectspecialchars=auto;
style Output from Container "Abstract. Controls basic output forms." /
backgroundcolor=colors('tablebg')
rules=NONE
frame=BOX
cellpadding=7
borderspacing=1
bordercollapse=separate;
style HeadersAndFooters from Cell "Abstract. Controls table headers and footers." /
font=fonts('HeadingFont')
color=colors('headerfg')
backgroundcolor=colors('headerbg');
style Caption from HeadersAndFooters "Abstract. Controls caption field in proc tabulate." /
borderspacing=0
cellpadding=0
color=colors('captionfg')
backgroundcolor=colors('captionbg');
end;
run;
Any help will be appreciated If someone can help me figure out which ODS styles control the PROC REPORT output? So I can add borderwidth or other relevant options.
Thank You!

Resolved finally. Turns out ODS Word doesn't work properly with custom styles. So instead used ODS RTF and used .doc instead of .docX

Related

Split labels of values on xaxis in a SAS graph into two lines

I have the below graph created by Proc sgplot. Since the labels of values on the xaxis is too long, I want to put them in two lines. For example, instead of "T2 to T3 (Pre-pandemic to initial pandemic)", I'd like to have
line 1: T2 to T3
line 2: (Pre-pandemic to initial pandemic)" .
I have created these labels using proc format. Thanks for your help.
Consider the options FITPOLICY and SPLITCHAR for the XAXIS statement.
For you, this would be
xaxis ... fitpolicy=split splitchar="(";
For further details, consult the documentation.

Coloring a table in apache superset

I want to color the background bars (or the entire cells) of the table as shown in the appended screenshot based on the "Group-By"/dimension value (red for "rot", yellow for "gelb" and green for "grĂ¼n").
I was able to color the metric-part of other visualizations with label_colors, but I have not yet found a way to color the cells of the table based on a "dimension".
Is there a way to do this?
As of now:
EDIT: I wanted to color it the following way (edited with paint):
This is a tad hacky, but you can add a markdown component and add the following markup:
<style>
th {
color: red; /* or whatever color/hex code you want */
}
</style>
The markdown component will be blank after you add this--i.e. there will just be a blank markdown block-- so you may want to add some copy. Alternatively, if you already have a markdown block, you can add it there, and it won't appear as long as you remember the <style></style> tags.

How can I change the color of inside borders only for header columns?

I want to have output a table into RTF that has no lines inside the table but has the inside border in header cells. In addition, the header column is colorful. I know how to change the border color for all the cells but I can't figure out how to only change the header ones. I need to do it with proc template. Right now I get this table:
But I need to have it like this:
The code is :
proc template;
define style styles.new;
parent = Styles.Printer;
replace color_list /
'link' = blue
'bgH' = cxFF8200
'bgT' = white
'bgD' = white
'fg' = black
'bg' = white;
replace Table from Output /
frame = hsides
rules = groups
cellpadding = 2pt
cellspacing = 0.25pt
borderwidth = 0.75pt
background = color_list('bgt') ;
end;
run;
ods listing style=new;
Could someone tell me please how could I change the code to get the correct output?
Thank you!
The white column header separation 'lines' you are seeing are not actually drawn.
Change to cellspacing=1in and you will observe that the 'lines' are actually artifacts of the spacing and correspond to the overall background. I don't think there is an easy way to have header cell borders that are different than data cell borders.

Trying to exclude procedure codes from the data

I am trying to exclude procedure codes from the data:
Excludes antipsychotic meds (Long-Acting Injections) dispensed
DATA CLMSPULL_NEW2;
SET CLMSPULL_NEW;
Excludes hospice codes
DATA CLMSPULL_NEW3;
SET CLMSPULL_NEW2;
These are the codes built into macros:
/*Exclusions*/
%LET HOSPICE =
('99377','99378','G0182','G9473','G9474','G9475','G9476',
'G9477','G9478','G9479','Q5003','Q5004','Q5005','Q5006','Q5007','Q5008','Q5010','S9126','T2042',
'T2043','T2044','T2045','T2046','0143', '0144', '0149', '0150', '0151', '0152', '0153', '0154',
'0159', '0160', '0164', '0167', '0169', '0200', '0201', '0202', '0203', '0204', '0206', '0207',
'0208', '0209', '0210', '0211', '0212', '0213', '0214', '0219', '0720', '0721', '0722', '0723',
'0724', '0729', '0987', '99221','99222','99223','99231','99232','99233',
'99238','99239','99251','99252','99253','99254','99255','99291');
/*Long-Acting Injections*/
%LET LAINJ = ('J0401','J1631','J2358','J2426','J2680','J2794');
Not very clear what you're asking, but here's an attemp, assuming you have in your dataset the two columns hospice and lainj:
proc sql;
create table CLMSPULL_cleaned as
select *
from CLMSPULL_NEW
where hospice not in &hospice
and lainj not in &laing;
quit;

Is it possible to use the 'where' statement in elasticnet (SAS)?

Here is the code I am using for variables selection:
proc glmselect data=abct;
where incex1=1;
title 'GLMSELECT with Elastic Net';
model devmood_c = asetot age yrseduc sex employyn cohabyn caucyn asitot penntot
anxdis ahealthuse ahospit ventxpwk acmn nhospit bmi comorb
aqllimmn aqlsubmn aqlsympmn aqlemotmn aqlenvirmn aqltotmn
smoke3gp nalcwkcurr
/selection=elasticnet(steps=120 L2=0.001 choose=validate);
run;
The problem is that, when I run it, it tells me:
ERROR: Variable incex1 is not on file WORK.ABCT.
This incex1 variable is used to exclude people in our database that have score too high on a particular question. It works with LASSO, but even though the code is similar, doesn't seem to work with elasticnet.
Does anyone know how I could use it or if there is another way to exclude the patients who scored under a certain threshold on a questionnaire?
This is how incex1 has been coded:
if devmood_c = 0 then incex1=1;
if devmood_c = 1 then incex1=1;
if devmood_c = . then incex1=0;
if bdisev > 2 then incex1=0;
label incex1 = "1=no mood at baseline or BDI > 20, 0=excluded";
This works in test data, so it is likely an issue with your source data not having the characteristics you expect. For example,
ods graphics on;
proc glmselect data=sashelp.Leutrain valdata=sashelp.Leutest
plots=coefficients;
where x1>0;
model y = x2-x7129/
selection=elasticnet(steps=120 l2=0.001 choose=validate);
run;
That works as expected.