A. What is gif?
- Graphic Interchange Format
- belongs to the bitmap family
- supported by major web browsers
- resolution: up to 8 bits per pixel
- supports animation
- not support audio
A journey of a thousand miles begins with the first step.
A. What is gif?
A. Purpose
The use of this SAS program is to produce excel files for each product, and within each excel product file, generate multiple sheets with different conditions, sheets names, titles.
B. Code
options symbolgen;
data parmlst;
infile datalines delimiter = '!';
length parm1 $60. parm2 $30. parm3 $40.;
input parm1 $ parm2 $ parm3 $ ;
call symput('parm1_'||left(_n_), parm1);
call symput('parm2_'||left(_n_), parm2);
call symput('parm3_'||left(_n_), parm3);
datalines;
engineSize le 3.5 ! EngineSize le 3.5! (Engine Size = $40,000)
;
run;
/* [S=] is [S=<parent>] */ %macro exlout (varname=, con=); %let i=1; %do %while (%scan(&con., &i, ' ') ne ); %let dsn=%scan(&con., &i, ' '); data &dsn.; set sashelp.cars; if &varname. = "&dsn."; count = 1; run; ods tagsets.Excelxp path= "X:\SAS\" file="Car_Profile_&varname._&dsn..xls" style=journal options (embedded_titles='yes' embedded_footnotes='yes' absolute_column_width='10,10,10,10' auto_height="no" ); %do j=1 %to 2; %put &j; ods tagsets.excelxp options (sheet_name="&&parm2_&j." sheet_interval='none'); title1 justify = left height = 22pt bold "Car Profile (&varname. = &dsn.) by Specifics"; title2 justify = left height = 20pt bold "Car Segment: &&parm3_&j. "; proc tabulate data = &dsn. S=[background=palg]; where &&parm1_&j.; class Type Make Origin engineSize Cylinders / S=[background=palg]; classlev Type Make Origin engineSize Cylinders / S=[background=palg]; var Horsepower MPG_City MPG_Highway Count/ S=[background=palg]; table Type all="Total"*[S=] Make all="Total"*[S=] Origin all="Total"*[S=] EngineSize="EngineSize" all="Total"*[S=] Cylinders all="Total"*[S=], (Horsepower*Mean="" MPG_City="MPG City"*Mean="" MPG_Highway="MPG City"*Mean="" Count="N"*SUM="" ) / box = [S=[background=palg]] ; keyword all / S=[background=lilg]; run; quit; %end; ods tagsets.excelxp close; %let i = %eval (&i +1); %end; ods tagsets.excelxp close; run; %mend exlout;
%exlout (varname=Origin, con=USA Europe); %exlout (varname=Type, con=Sedan SUV);
C. Output


D. Key Coding Elements
/*Original table*/ proc tabulate data =table1 ; class Agegroup gender acadyear; var heads; table agegroup="Age Group" all gender="Gender" all , (acadyear="")*(heads="Heads"*SUM="" heads="% Total"*pctsum < agegroup all gender all > ="" ); run;

/* Change body to light green */ proc tabulate data =table1 S=[background=lightgreen] ; class Agegroup gender acadyear; var heads; table agegroup="Age Group" all gender="Gender" all , (acadyear="")*(heads="Heads"*SUM="" heads="% Total"*pctsum <agegroup all gender all > ="" ); run;

/* Change Class Variable Colour */ proc tabulate data =table1 S=[background=lightgreen] ; class Agegroup gender acadyear / S=[background=lightgreen]; var heads; table agegroup="Age Group" all gender="Gender" all , (acadyear="")*(heads="Heads"*SUM="" heads="% Total"*pctsum < agegroup all gender all > ="" ); run;

/* Change var variable column heading colour */ proc tabulate data =table1 S=[background=lightgreen] ; class Agegroup gender acadyear / S=[background=lightgreen]; var heads / S=[background=lightgreen]; table agegroup="Age Group" all gender="Gender" all , (acadyear="")*(heads="Heads"*SUM="" heads="% Total"*pctsum < agegroup all gender all > ="" ); run;

/* Change Box colour */ proc tabulate data =table1 S=[background=lightgreen] ; class Agegroup gender acadyear / S=[background=lightgreen]; var heads / S=[background=lightgreen] ; table agegroup="Age Group" all gender="Gender" all , (acadyear="")*(heads="Heads"*SUM="" heads="% Total"*pctsum < agegroup all gender all > ="" ) / box =[S=[background=lightgreen]]; run;

/* Change Class categories colour */ proc tabulate data =table1 S=[background=lightgreen] ; class Agegroup gender acadyear / S=[background=lightgreen]; classlev Agegroup gender acadyear / S=[background=lightgreen]; var heads / S=[background=lightgreen] ; table agegroup="Age Group" all gender="Gender" all , (acadyear="")*(heads="Heads"*SUM="" heads="% Total"*pctsum < agegroup all gender all > ="" ) / box =[S=[background=lightgreen]]; run;quit;

/* Change Colour of 'All' field */ proc tabulate data =table1 S=[background=lightgreen] ; class Agegroup gender acadyear / S=[background=lightgreen]; classlev Agegroup gender acadyear / S=[background=lightgreen]; var heads / S=[background=lightgreen] ; table agegroup="Age Group" all gender="Gender" all , (acadyear="")*(heads="Heads"*SUM="" heads="% Total"*pctsum < agegroup all gender all > ="" ) / box =[S=[background=lightgreen]]; keyword all / S=[background=green]; run;

/* Rename 'All' to 'Total'. Change 'Total' row colour Across the table. */ /* Method 1 */ proc tabulate data =table1 S=[background=lightgreen] ; class Agegroup gender acadyear / S=[background=lightgreen]; classlev Agegroup gender acadyear / S=[background=lightgreen]; var heads / S=[background=lightgreen] ; table agegroup="Age Group" all="Total"*[s=] gender="Gender" all="Total"*[s= < parent >] , (acadyear="")*(heads="Heads"*SUM="" heads="% Total"*pctsum < agegroup all gender all > ="" ) / box =[S=[background=lightgreen]]; keyword all / S=[background=green]; run; /* Method 2 */ proc tabulate data =table1 S=[background=lightgreen] ; class Agegroup gender acadyear / S=[background=lightgreen]; classlev Agegroup gender acadyear / S=[background=lightgreen]; var heads / S=[background=lightgreen] ; table agegroup="Age Group" all="Total"*[S=[background=green]] gender="Gender" all="Total"*[S=[background=green]] , (acadyear="")*(heads="Heads"*SUM="" heads="% Total"*pctsum < agegroup all gender all > ="" ) / box =[S=[background=lightgreen]]; keyword all / S=[background=green]; run;

/* Add All column Total. Override colour of All column */
proc tabulate data =table1 S=[background=lightgreen] ;
class Agegroup gender acadyear / S=[background=lightgreen];
classlev Agegroup gender acadyear / S=[background=lightgreen];
var heads / S=[background=lightgreen] ;
table agegroup="Age Group" all="Total"*[S=[background=green]] gender="Gender" all="Total"*[S=[background=green]] ,
(acadyear="" all={label="All Years" S=[background=lightgreen]} )*(heads="Heads"*SUM="" heads="% Total"*pctsum < agegroup all gender all > ="" )
/ box =[S=[background=lightgreen]];
keyword all / S=[background=green];
run;

A. PowerBI Free and Pro versions


A. Usage
B. Code
%let newvar = %substr(&var., 3, %length(&var.)-2); *Newvar is trimming the first 2 characters off the var;
A. Multiple Titles/Footnotes
title title2 title3 footnote footnote2 footnote3
B. Alignment: default is center.
justify=
C. Font
f=
D.Bold/Italic
bold italic
E. Font size
h=
F. Example
title1 f='Calibri' h=14pt 'Report Title'; title2 "Report Title1"; title3 "Report Title2"; footnote "Prepared by First Last on %sysfunc(date(),worddate.)"; footnote2 justify=left h=8pt bold "Note:"; footnote3 justify=left h=8pt italic "footnote3";
A. Extract Month, Year information from DateTime.
date=datepart(datetime); year=year(date); month=month(date);
B. Date Value for Date Comparison
C. Age calculation
age = intck('Year', birth, "01JUL&yr."D, 'C');
A. Different Standard Errors
B. Estimate function in the GLM procedure
A. Symptom
The plots stopped showing in the pane when running the R codes. The temporary png file generated in the folder didn’t have the graphic output and the file was not able to be deleted.
B. R Code Caused problem
png(file='Construct.png') subgroup.analysis.mixed.effects(x = m.hksj, subgroups = madata$Construct, plot=TRUE) dev.off
In R use png(file=) and dev.off to generate graphic output in the working directory. The subgroup.analysis.mixed.effect function doesn’t work with this method, hence the output graphic file got stuck.
C. Fix
dev.cur() # to identify output device as "png 4"
dev.off() # to identify "null device" so the png file in the folder can be deleted;
getOption("device") # to set option to "RStudioGD"
A. Update R through RGui
install.packages("installr")
library(installr)
