I am using GKPI to create a SPEEDOMETER dashboard as shown below. How can I send this Speedometer embedded (not as an attachment) in an e-mail.
PROC GKPI
mode=raised;
speedometer actual = &Percentage
bounds=(0 .60 .80 1) / target = .85
colors=(red yellow green)
activecolors=(red yellow green)
format = "percent8.0"
lfont=(f="Albany AMT/bold" height=.5cm)
label = "STL RFID Utilization";
run;
quit;
Related
I am having a dataset of multiple products with it's average rating over the months.
I want to ask how can we do row formatting for example: If the rating of a product keeps on increasing, color it with green else if it's decreasing it should have red color.
I want all this to be done in Power BI.
Sample Data:
With this format of the data, you will have to create a measure for each of the columns you want to colorize. Here are the measures (assuming Table is the name of your table):
June background = IF(SUM('Table'[June]) < SUM('Table'[May]), "RED", "GREEN")
July background = IF(SUM('Table'[July]) < SUM('Table'[June]), "RED", "GREEN")
August background = IF(SUM('Table'[August]) < SUM('Table'[July]), "RED", "GREEN")
September background = IF(SUM('Table'[September]) < SUM('Table'[August]), "RED", "GREEN")
Add a table visual to the report with the columns from your sample and for June to September repeat the following. Right click the column in the values pane and select Conditional formatting -> Background color:
This will open a window, where you can select how to determine the formatting and shall it apply it to values only, totals only or both. Select to format it by field value and choose the corresponding measure for the column, like this:
Repeat that for the rest of the columns to get this result:
For more information, take a look at Use conditional formatting in tables article.
I'm new to SAS and would like to get help with the question as follows:
1: Sample table shows as below
Time Color Food label
2020 red Apple A
2019 red Orange A,B
2018 blue Apple A,B
2017 blue Orange B
Logic to return label is:
when color = 'red' then 'A'
when color = 'blue' then 'B'
when food = 'orange' then 'B'
when food = 'apple' then 'A',
since for row 2, we have both red and orange then our label should contains both 'A,B', same as row 3.
The requirement is to print out the label for each combination. I know that we can use CASE WHEN statement to define how is our label should be based on color and food. Here we only have 2 kind of color and 2 different food, but what if we like 7 different color and 10 different food, then we would have 7*10 different combinations. I don't want to list all of those combinations by using case when statement.
Is there any convenient way to return the label? Thanks for any ideas!(prefer to achieve it in PROC SQL, but SAS is also welcome)
This looks like a simple application of formats. So define a format that converts COLOR to a code letter and a second one that converts FOOD to a code letter.
proc format ;
value color 'red'='A' 'blue'='B';
value food 'Apple'='A' 'Orange'='B' ;
run;
Then use those to convert the actual values of COLOR and FOOD variables into the labels. Either in a data step:
data want;
set have ;
length label $5 ;
label=catx(',',put(color,color.),put(food,food.));
run;
Or an SQL query:
proc sql ;
create table want as
select *
, catx(',',put(color,color.),put(food,food.)) as label length=5
from have
;
run;
You do not need to re-create the format if the data changes, only if the list of possible values changes.
I want to plot Y by X plot where I group by year, but color code year based on different variable (dry). So each year shows as separate line but dry=1 years plot one color and dry=0 years plot different color. I actually figured one option (yeah!) which is below. But this doesn't give me much control.
Is there a way to put a where clause in the series statement to select specific categories so that I can specifically assign a color (or other format)? Or is there another way? This would be analogous to R where one can use multiple line statements for different subsets of data.
Thanks!!
This code works.
proc sgplot data = tmp;
where microsite_id = "&msit";
by microsite_id ;
yaxis label= "Pct. Stakes" values = (0 to 100 by 20);
xaxis label= 'Date' values = (121 to 288 by 15);
series y=tpctwett x=jday / markers markerattrs=(symbol=plus) group = year grouplc=dry groupmc=dry;
format jday tadjday metajday jdyfmt.;
label tpctwett='%surface water' tadval1='breed' metaval1='meta';
run;
Use an Attribute map, see the documentation
You can use the DRY variable to set the specific colours. For each year, assign the colour using the DRY variable in a data step.
proc sort data=tmp out=attr_data; by year; run;
data attrs;
set attr_data;
id='year';
if dry=0 then linecolor='green';
if dry=1 then linecolor='red';
keep id linecolor;
run;
Then add the dattrmap=attrs in the PROC SGPLOT statement and the attrid=year in the SGPLOT options.
ods graphics / attrpriority=none;
proc sgplot data = tmp dattrmap=attrs;
where microsite_id = "&msit";
by microsite_id ;
yaxis label= "Pct. Stakes" values = (0 to 100 by 20);
xaxis label= 'Date' values = (121 to 288 by 15);
series y=tpctwett x=jday / markers markerattrs=(symbol=plus) group = year grouplc=dry groupmc=dry attrid=year;
format jday tadjday metajday jdyfmt.;
label tpctwett='%surface water' tadval1='breed' metaval1='meta';
run;
Note that I tested and edited this post so it should work now.
I'm using the following code in sas:
goptions reset=all border ;
goptions colors=(yellow steel purple pink red blue cyan orange green gray
black);
title1 "Congo";
title2 "11 Regions";
footnote j=r "Congo ";
proc gmap map=mapsgfk.dr_congo data=mapsgfk.dr_congo all density=6;
id id1;
choro id1/discrete;run;
quit;
and it generates the following map:
How do I remove the white space inside some of the regions?
The map data is segmented at the ID level. The ID1 value is a truncation of ID. The 'white-space' is due to a segment being associated to an id it does not belong to. Try:
proc gmap
map=mapsgfk.dr_congo data=mapsgfk.dr_congo all density=6
;
* simpler statements per DCR comment, removed format;
id id;
choro id1 / discrete;
run;
quit;
I believe there may still be some issues regarding lakes being drawn with a color.
Currently I use following code to output pdf.
GOPTIONS device=ACTXIMG;
ods pdf file="....\Daily Performance &CDate..pdf";
title 'Daily Performance';
proc tabulate data=DailyReport s=[just=c] missing;
class Area Period/order=data preloadfmt;
format Area $Areaformat. Period $Periodformat.;
var Units Uti Vari;
table (Area='' ),
(Units={Label="Units"}*(mean=''*f=comma6.)
Uti={Label="Uti"}*(sum=''*f=percent8.1)
Vari={Label="Var."}*(mean=''*f=percent8.1))/box="&CDate";
run;
ods pdf close;
But in some cases I have 20-30 columns in a tabulated output. If I use above code, then the table will be break into 2 or more pages in PDF.
So Is there a way to make it "vertical" in pdf? Or a way to keep it horizontal while compressed into one-page?
Change your page orientation using option orientation.
option orientation=landscape;
You change change the orientation within the document by changing the option between procs.