SAS Proc Template: Only Outside Table Border Control - templates

I have a custom PROC TEMPLATE essentally all set up except that I cannot get ONLY the outside frame of the table to be double lines. I can get the top of the table to be double when I use:
STYLE TABLEHEADERCONTAINER /
BORDERTOPSTYLE=DOUBLE
;
But the bottom of the table will not show a double line when I use:
STYLE TABLEFOOTERCONTAINER /
BORDERTOPSTYLE=DOUBLE
;
Nor does the above work with BORDERBOTTOMSTYLE. On top of this issue, I am unable to get the left and right sides of the table to have double lines. Can anyone offer any insight into this? Below is my entire template:
** CREATE CUSTOM STYLE WITH ARIAL 10 PT **;
PROC TEMPLATE;
DEFINE STYLE STYLES.STARFOX;
PARENT=STYLES.RTF;
STYLE USERTEXT FROM USERTEXT / FONTSIZE=3.5 FONTSTYLE=ROMAN JUST=L; /*INFO FOR THE ODS TEXT STATEMENTS*/
STYLE FONTS /
'TITLEFONT2' = ("<SANS-SERIF>, <MTSANS-SERIF>, ARIAL",2,BOLD)
'TITLEFONT' = ("<SANS-SERIF>, <MTSANS-SERIF>, ARIAL",3,BOLD)
'STRONGFONT' = ("<SANS-SERIF>, <MTSANS-SERIF>, ARIAL",2,BOLD)
'EMPHASISFONT' = ("<SANS-SERIF>, <MTSANS-SERIF>, ARIAL",2)
'FIXEDFONT' = ("<MONOSPACE>, COURIER",2)
'BATCHFIXEDFONT' = ("SAS MONOSPACE, <MONOSPACE>, COURIER, MONOSPACE",2)
'FIXEDHEADINGFONT' = ("<MONOSPACE>, COURIER, MONOSPACE",2)
'FIXEDSTRONGFONT' = ("<MONOSPACE>, COURIER, MONOSPACE",2,BOLD)
'FIXEDEMPHASISFONT' = ("<MONOSPACE>, COURIER, MONOSPACE",2)
'HEADINGEMPHASISFONT' = ("<SANS-SERIF>, <MTSANS-SERIF>, ARIAL",2,BOLD )
'HEADINGFONT' = ("<SANS-SERIF>, <MTSANS-SERIF>, ARIAL",2,BOLD)
'DOCFONT' = ("<SANS-SERIF>, <MTSANS-SERIF>, ARIAL",2);
;
STYLE TABLEHEADERCONTAINER /
BORDERTOPSTYLE=DOUBLE
;
STYLE TABLEFOOTERCONTAINER /
BORDERTOPSTYLE=DOUBLE
;
STYLE DATA /
FONT_FACE = "ARIAL"
FONT_SIZE = 10PT
JUST=CENTER
VJUST=C
;
STYLE TABLE /
CELLSPACING = 0.7
CELLPADDING = 1.4
FONT_SIZE = 10
JUST=CENTER
VJUST=C
BORDERWIDTH=1
FRAME=BOX
;
STYLE HEADER /
FONT_FACE = "ARIAL"
FONT_SIZE = 10PT
FONT_WEIGHT = BOLD
JUST=CENTER
VJUST=C
;
STYLE ROWHEADER /
FONT_FACE = "ARIAL"
FONT_SIZE = 10
JUST=CENTER
VJUST=C
;
STYLE FOOTER /
FONT_FACE = "ARIAL"
FONT_SIZE=10
JUST=CENTER VJUST=C
;
REPLACE COLOR_LIST /
"BG" = WHITE
"FG" = BLACK
"BGH" = WHITE
"LINK" = BLUE;
STYLE BODY FROM DOCUMENT /
TOPMARGIN=.8IN
BOTTOMMARGIN=.8IN
RIGHTMARGIN=.9IN;
END;
RUN;
Below is how the output table appears:
And I would like it to appear as:

Related

Making Power Bi - R (HTMLwidgets pbiviz based) custom visuals interactive with other Power BI visuals

I have made a pbiviz custom visual using developer tools of Normal distribution curve over a Histogram plot with R - ggplot2 and plotly libraries in a pbiviz.package
The visual works fine. Now I want to add interactivity of the Histogram with other Power BI visuals.
i.e. If user clicks on a bar of the Histogram, it should filter out a Table on my PBI report with rows relevant to the histogram bar data.
Considering the limitations of using R script with Power BI, I do not know if it is possible with my current visual as I am new to scripting.
Is there a better way (Typescript, JS, Python, etc.) other than what I have done to make an Interactive Histogram & Distribution Curve in Power BI?
This is the R script along with sample data and Visual Image
Histogram represents the projects falling in different durations
There are two bell curves - One for closed projects and Other for Active Projects
source('./r_files/flatten_HTML.r')
############### Library Declarations ###############
libraryRequireInstall("ggplot2");
libraryRequireInstall("plotly");
libraryRequireInstall("tidyverse");
libraryRequireInstall("scales");
libraryRequireInstall("htmlwidgets");
library(ggplot2)
library(tidyverse)
library(scales)
library(plotly)
theme_set(theme_bw())
##### Making DataSet for All Selected Projects #####
Duration <- dataset$Duration
Status <- (rep(dataset$ProjectStatus))
da <- data.frame(Duration,Status)
lenx <- length(Duration)
meanall <- mean(da$Duration)
sdx <- sd(da$Duration)
binwidth <- 30
font_label <- list(family = "Segoe UI", size = 21, colour = "black")
hovlabel <- list(bordercolor = "black", font = font_label)
#Filtering Out Closed Projects from Dataset
#Creating Data Frame for Closed Projects
closedproj <- dataset %>%
select(Duration,ProjectStatus) %>%
filter(ProjectStatus == "Closed")
closed <- closedproj$Duration
df <- data.frame(closed)
xclosed <- closedproj$
df2 <- data.frame(xclosed)
lenc <- length(xclosed)
mean_closed <- mean(df2$xclosed)
sdc <- sd(df2$xclosed)
a <-
(ggplot(da,aes(x=Duration, fill = Status, text = paste("Duration: ",x,"-", x + binwidth,"<br />Project Count", ..count..)))+
#Histogram
geom_histogram(aes(y=..count..),alpha=0.5, position='identity',binwidth = binwidth)+
# #Distribution Curve
annotate(
geom = "line",
x = da$Duration,
y = dnorm(da$Duration, mean = meanall, sd = sdx) * lenx * binwidth,
width = 3,
color = "red"
) +
annotate(
geom = "line",
x = df2$xclosed,
y = dnorm(df2$xclosed, mean = mean_closed, sd = sdc)* lenc * binwidth,
width = 3,
color = "blue"
) +
labs(
x = "Project Duration (Days)",
y = "Project_Count",
fill = "Project Status")+
#Mean
geom_vline(aes(xintercept=meanall),color="red",linetype="dashed",size = 0.8,label=paste("Mean :",round(meanall,0)))+
geom_vline(aes(xintercept=mean_closed),color="blue",linetype="dashed",size = 0.8,label=paste("Mean (Closed):",round(mean_closed,0)))+
# 1 Sigma
geom_vline(aes(xintercept = (meanall + sdx)), color = "red", size = 1, linetype = "dashed") +
geom_vline(aes(xintercept = (meanall - sdx)), color = "red", size = 1, linetype = "dashed")+
geom_vline(aes(xintercept = (mean_closed + sdc)), color = "blue", size = 1, linetype = "dashed") +
geom_vline(aes(xintercept = (mean_closed - sdc)), color = "blue", size = 1, linetype = "dashed")+
# Theme
theme(
plot.background = element_rect(fill = "transparent"),
legend.background = element_rect(fill = "lightgray"),
axis.title.x = element_text(colour = "Black",size = 18,face = "bold"),
axis.title.y = element_text(colour = "Black",size = 18,face = "bold"),
axis.text.x = element_text(colour = "Black",size = 15),
axis.text.y = element_text(colour = "Black",size = 15),
panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
scale_x_continuous(labels = comma,
breaks = seq(0, max(Duration),50)) +
scale_y_continuous(labels = comma,
breaks = seq(0,max(Duration),10)))
############# Create and save widget ###############
p = ggplotly(a, tooltip = c("text")) %>%
style(hoverlabel = hovlabel) %>%
layout(legend = list(
orientation = "h",
x = 0,
y = 1.13,
title = list(text = "Project Status",font = list(family = "Segoe UI", size = 23)),
font = font_label
),
yaxis = list(title = list(standoff = 25L)),
xaxis = list(title = list(standoff = 25L)),
annotations = list(showarrow=FALSE,align = "left",valign = "top",x = 0.95, xref = "paper",yref = "paper",y = 0.955,
font = list(family = "Segoe UI", size = 22, color = "#cc0000"),
text = paste("Max Duration: ", comma(round(max(da$Duration),0)),
"<br>Mean (Closed): ", comma(round(mean_closed,0)),
"<br>Mean (All) : ", comma(round(meanall,0))))
) %>%
config(modeBarButtonsToRemove = c("select2d","hoverClosestCartesian", "lasso2d","hoverCompareCartesian","toggleSpikelines"), displaylogo = FALSE);
internalSaveWidget(p, 'out.html');
}
####################################################
################ Reduce paddings ###################
ReadFullFileReplaceString('out.html', 'out.html', ',"padding":[0-5]*,', ',"padding":0,')
What I expect is -- If user clicks on a bar of the Histogram, it should reflect on a Table visual on my PBI report with rows relevant to the histogram bar data.
Any help will be highly appreciated !
Regards

customized summary in proc report sas

I need a report with a customized summary, the next report shows the fields in the test data set and the total results are the sum of each variable. I want the total value to be the total of the variable num divided by the total of the variable tot. i.e. 68/194 = 35.05%, and not the sum of the percentages in the rate variable.
data test;
input rank num tot rate;
datalines;
1 20 50 0.4
2 15 30 0.5
3 28 52 0.538461538461538
4 5 62 0.0806451612903226
;
run;
proc report data = _last_ box spacing = 1 split = "/"
style(header) = [font_face = "courier new"] style(column) = [font_face =
"courier new"]
style(lines) = [font_face = "courier new"] style(report) = [font_face =
"courier new"]
style(summary) = [font_face = "courier new" font_style = roman];
column(rank num tot rate);
define rank / " Rank " center width = 6 format = 5. order
order = data;
define num / " N " center width = 6 format = 5.;
define tot / " Total " center width = 6 format = 5.;
define rate / " Rate " center width = 6 format =
percent9.2 ;
rbreak after / summarize style = [font_weight = bold];
run;
Add compute block after summarize.
proc report data = _last_ box spacing = 1 split = "/"
style(header) = [font_face = "courier new"] style(column) = [font_face =
"courier new"]
style(lines) = [font_face = "courier new"] style(report) = [font_face =
"courier new"]
style(summary) = [font_face = "courier new" font_style = roman];
column(rank num tot rate);
define rank / " Rank " center width = 6 format = 5. order
order = data;
define num / " N " center width = 6 format = 5.;
define tot / " Total " center width = 6 format = 5.;
define rate / " Rate " center width = 6 format =
percent9.2 ;
rbreak after / summarize style = [font_weight = bold];
compute after;
rate.sum=num.sum/tot.sum;
endcomp;
run;
You're nearly there - I think you just need to specify analysis mean when you define the variable rate:
data test;
input rank num tot rate;
datalines;
1 20 50 0.4
2 15 30 0.5
3 28 52 0.538461538461538
4 5 62 0.0806451612903226
;
run;
proc report data = _last_ box spacing = 1 split = "/"
style(header) = [font_face = "courier new"] style(column) = [font_face =
"courier new"]
style(lines) = [font_face = "courier new"] style(report) = [font_face =
"courier new"]
style(summary) = [font_face = "courier new" font_style = roman];
column(rank num tot rate);
define rank / " Rank " center width = 6 format = 5. order order = data;
define num / " N " center width = 6 format = 5.;
define tot / " Total " center width = 6 format = 5.;
define rate / " Rate " center width = 6 format = percent9.2 analysis mean;
rbreak after / summarize style = [font_weight = bold];
run;
quit;

Python auto select color bar

I want to set color bar "green" when data direction1 = 005.
How to make it auto select color bar in Python 2.7 from these case?:
direction1=['200','250','180','200','300','270','005','080']
time1=['0000','0030','0100','0130','0200','0230','0300','0300']
Current script as follows :
ind = np.arange(len(time1))
width = 0.50
rects1 = plt.bar(ind, direction1, width, color='r')
for x in range(0,len(direction1)):
if x in direction1==005:
rects1[x].set_color('g')
This is the answer for sharing:
values=np.array(direction1)
searchval = '005'
location = np.where(values == searchval)[0]
print location
rects1 = plt.bar(ind, direction1, width, color='r')
for x in location:
rects1[x].set_color('g')
Cheers!!!...

Python for loop doesn't work right when it is inside of the command of a button

from Tkinter import *
import tkFileDialog
import sys
def openwindows():
eText.set(open.show())
def loadfiles():
filedirectory=eText.get()
f=file(filedirectory)
lines = f.readlines()
length=len(lines)
#vertex=[]
#face=[]
for x in range(0,length):
print (x)
Root=Tk()
RTitle=Root.title("Assignment_2")
RWidth=Root.winfo_screenwidth()
RHeight=Root.winfo_screenheight()
Root.geometry("%dx%d+%d+%d" % (RWidth/3,RHeight/3*2,RWidth/2-RWidth/6, RHeight/2-RHeight/3))
frame1 = Frame(Root)
frame1.pack()
Label(frame1, text="Filename: ").pack(side = LEFT)
eText = StringVar()
statusbar = Entry(frame1, state="readonly", textvariable=eText)
eText.set("pyramid.txt")
statusbar.pack(side = LEFT)
myfiletypes = [('text files', '*.txt'), ('All files', '*')]
open = tkFileDialog.Open(frame1, filetypes = myfiletypes)
Button(frame1, text="Browse", fg = "Blue", command=openwindows).pack(side = LEFT)
Button(frame1, text = "Load", fg = "red", command=loadfiles).pack(side=LEFT)
frame2 = Frame(Root)
frame2.pack()
Label(frame2, text="Rotation Axis: ").pack(side=LEFT)
r1 = IntVar()
r1.set(3)
Radiobutton(frame2, text="X", variable=r1, value=1).pack(side=LEFT)
Radiobutton(frame2, text="Y", variable=r1, value=2).pack(side=LEFT)
Radiobutton(frame2, text="Z", variable=r1, value=3).pack(side=LEFT)
Radiobutton(frame2, text="Line AB", variable=r1, value=4).pack(side=LEFT)
Label(frame2, text="A:").pack(side=LEFT)
pointA = Entry(frame2, width=10)
pointA.insert(0, "[0.0,0.0,0.0]")
pointA.pack(side=LEFT)
Label(frame2, text="B:").pack(side=LEFT)
pointB = Entry(frame2, width=10)
pointB.insert(0, "[1.0,1.0,1.0]")
pointB.pack(side=LEFT)
var1 = StringVar(Root)
var1.set("90")
Label(frame2, text="Degree:").pack(side=LEFT)
Spinbox(frame2, width=3, from_=0, to=350, increment=10, textvariable=var1).pack(side=LEFT)
var2 = StringVar(Root)
var2.set("5")
Label(frame2, text="Steps:").pack(side=LEFT)
Spinbox(frame2, width=3, from_= 1, to = 10, textvariable=var2).pack(side=LEFT)
Button(frame2, text = "Rotate", fg = "Blue").pack(side=LEFT)
frame3 = Frame(Root)
frame3.pack()
Label(frame3, text="Scale Ratio: ").pack(side=LEFT)
r2 = IntVar()
r2.set(1)
Radiobutton(frame3, text="All", variable=r2, value=1).pack(side=LEFT)
var3 = StringVar(Root)
var3.set("1")
Spinbox(frame3, width=4, from_= 0.25, to = 4, textvariable=var3, increment=0.25, format='%3.2f').pack(side=LEFT)
Radiobutton(frame3, text="[Sx,Sy,Sz]", variable=r2, value=2).pack(side=LEFT)
scaleamount = Entry(frame3, width=10)
scaleamount.insert(0, "[1,1,1]")
scaleamount.pack(side=LEFT)
var4 = StringVar(Root)
var4.set("4")
Label(frame3, text="Steps:").pack(side=LEFT)
Spinbox(frame3, width=3, from_= 1, to = 10, textvariable=var4).pack(side=LEFT)
Button(frame3, text = "Scale", fg = "Blue").pack(side=LEFT)
separator = Frame(height=2, bd=1, relief=SUNKEN)
separator.pack(fill=X, padx=5, pady=5)
Canvas(Root, bg="Blue").pack(fill="both", expand=True)
mainloop()
when you click Load, its suppose to read the file and display this.
0
1
2
3
4
5
6
7
.....
whatever number of lined you have in the txt file.
But the problem is that, it only displays this
0
which means the for loop only ran one time and thats it.
if I close the program, then the rest of the numbers will show in the command prompt.
really weird... doesnt make sense.
the loadfiles() itself works perfectly fine.
It just wont work with the button
The issue has to do with how the UI is processing.
Try replacing print (x) with
sys.stdout.write(str(x) + '\n') # or "{}\n".format(x)
sys.stdout.flush()
If you search for tkinter and flush you will find plenty of conversations to read.

MSChart - Multiple columns grouped by date

I need to display % utilization for several production lines over several days. So my Y axis will be the % values. I need bars for each of the production lines on each of the days. So my X axis would be groups of columns each labeled for the production line and then grouped and labeled for the date. How would I do this with the MSchart.
Below is a sample of what I need. It shows only 2 production lines (I will need to display more than 2 production lines) and does not include the production line name in the X-axis label.
I am almost there. Here is an image of the chart I am creating:
And here is the code that created it:
Private Sub ChartSetup()
Try
dvCapacityUtilization.RowFilter = ""
dvCapacityUtilization.Sort = "Period ASC, CutUpSet ASC"
Me.cuChart.BeginInit()
With Me.cuChart
.ChartAreas(0).AxisX.Interval = 30
.ChartAreas(0).AxisX.LabelStyle.Format = "MM/yy"
.ChartAreas(0).AxisX.LabelStyle.Angle = -90
.ChartAreas(0).AxisY.MajorGrid.LineColor = Color.Gray
.ChartAreas(0).AxisX.MajorGrid.LineColor = Color.White
.ChartAreas(0).AxisX.MinorGrid.LineColor = Color.White
.DataBindCrossTable(dvCapacityUtilization, _
"CutUpSet", "Period", "CapacityUtilization", "Label = CapacityUtilization")
End With
'
For Each series In Me.cuChart.Series
series.IsValueShownAsLabel = False
series.LabelFormat = "0.0%"
series.SetCustomProperty("PointWidth", "0.5")
series.SetCustomProperty("DrawingStyle", "Cylinder")
series.XValueType = DataVisualization.Charting.ChartValueType.Date
Next
Me.cuChart.EndInit()
Catch ex As Exception
ErrHandler(Me.Name & " - Chart Setup", ex)
End Try
End Sub
How do I turn the value labels off? In my code I used IsValueShownAsLabel = False but they are still displayed. I eventually will allow the user to turn the values on or off.
How do I format the values as XX.X%. In my code I used LabelFormat = 0.0% but that did not work.
How can I get the X axis labels to be the dates associated with the data values. In my code I used AxisX.Interval = 30 just to get the labels on the chart.
Follow up:
As stated in #1 above, I used series.IsValueShownAsLabel = False but the value labels were still displayed. To remove them I had to do the following:
For Each point in series.Points
point.Label = String.Empty
Next
Why should I have to do this instead of using IsValueShownAsLabel = False?
WINFORM : Finally find out with some R&D. Please follow below steps.
1. Drag and Drop new chart control from ToolBox in new winform.
2. Remove default "Series1" as it's dynamically generated as per column values.
3. Assume that we have following sample datatable.
public DataTable GetDataTable()
{
DataTable dt = new DataTable();
dt.Columns.Add("UtilizationDate", typeof(DateTime));
dt.Columns.Add("ProductionLine", typeof(string));
dt.Columns.Add("UtilizationValue", typeof(int));
DataRow dr = dt.NewRow();
dr[0] = DateTime.Now;
dr[1] = "Proy01";
dr[2] = 25;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = DateTime.Now;
dr[1] = "Proy02";
dr[2] = 15;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = DateTime.Now;
dr[1] = "Proy03";
dr[2] = 125;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = DateTime.Now.AddMonths(1);
dr[1] = "Proy01";
dr[2] = 13;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = DateTime.Now.AddMonths(1);
dr[1] = "Proy02";
dr[2] = 111;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = DateTime.Now.AddMonths(1);
dr[1] = "Proy03";
dr[2] = 77;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = DateTime.Now.AddMonths(2);
dr[1] = "Proy01";
dr[2] = 13;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = DateTime.Now.AddMonths(2);
dr[1] = "Proy02";
dr[2] = 111;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[0] = DateTime.Now.AddMonths(2);
dr[1] = "Proy03";
dr[2] = 77;
dt.Rows.Add(dr);
return dt;
}
4. Now add following line of code using DataBindCrossTable.
chart1.ChartAreas["ChartArea1"].AxisX.IntervalType = DateTimeIntervalType.Months;
chart1.ChartAreas["ChartArea1"].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.LabelStyle.Format = "MM-yy";
DataTable dt = GetDataTable();
chart1.DataBindCrossTable(dt.DefaultView, "ProductionLine", "UtilizationDate", "UtilizationValue", "Label=UtilizationValue");
foreach (Series item in chart1.Series)
{
item.IsValueShownAsLabel = true;
item["PixelPointWidth"] = "50";
item["DrawingStyle"] = "Cylinder";
item.XValueType = ChartValueType.DateTime;
}