Proc Report :
The REPORT procedure (PROC REPORT) combines features of the PRINT, TABULATE, and MEANS procedures, along with features of the DATA step, in a single report-writing tool that can be to produce a variety of reports.
It is useful to print all or selected variables, Find outs descriptive statistics and computes new variables.
Syntax:-
PROC REPORT <OPTIONS>;
COLUMN VARIABLE-LIST;
DEFINE REPORT-ITEM / <USAGE> <OPTION(S)>;
BREAK LOCATION BREAK-VARIABLE </OPTION(S)>;
RBREAK LOCATION / <OPTIONS>;
COMPUTE VARIABLE/<OPTIONS>;
RUN;
Difference between Proc print and Proc report
There is no OBS column in Report
Variable labels are used instead of column names
It is possible to calculate summary statistics and new columns with PROC REPORT
Column headers are adjusted to column width not the other way around
The procedure is potentially interactive (turned off with the NOFS option)
Options:-
Proc import datafile=”E:\PROCS_PRACTICE\PROC REPORT\Demo.csv”
Out=ds dbms=csv replace;
Run;
DATA=Dataset: Specify the input data set
Default proc report prints latest created dataset
Proc report data= ds;
Run;
OUT=Dataset: Specify the output data set
Proc report data= ds out=ds2;
Run;
BOX: Report the data within box in output window, default print without box.
Proc report data= ds out=ds2 box;
Run;
This option won’t work with ods statement.
BYPAGENO=number:
If a BY statement is present, specifies the listing page number at the start of each BY group.
Proc sort data=demo;
by sex;
Run;
Proc report data=demo nowd box bypageno=5 ;
By sex;
Run;
CENTER | NOCENTER: Specifies alignment of report.
Default is center, when we specify nocenter it prints left aligned.
Proc report data=demo nowd box bypageno=5 nocenter ;
Column emp_id emp_name sex age income;
Run;
NOWD | NOWINDOW: Suppress to printing of proc report window and prints report in output or result viewer window.
Select the interactive report window or the non windowing environment
Default proc report prints data in Proc report window
Proc report data= ds nowd;
Run;
HEAD SKIP: Insert space between column name and data in output window.
Proc report data= ds nowd headskip;
Run;
HEAD LINE: Insert line between column names and data in output window.
Proc report data= ds nowd headskip headline;
Run;
LIST: Writes proc report code in sas log.
Proc report data=ds nowd list ;
Column emp_id emp_name sex age income;
Run;
LS=Line Size: specifies the length of a line of the report.
Line size should be 64-256.
PS=Page Size: specifies no of lines in page..
Page size should be 15-32767.
Proc report data=ds nowd ls=200 ps=100;
Column emp_id emp_name sex age income;
Run;
Named: writes name= in front of each value in the report, where name is the column heading for the value.
Proc report data=ds nowd named;
Column emp_id emp_name sex age income;
Run;
NOHEADER: suppresses column headings, including headings that span multiple columns.
Proc report data=ds nowd noheader;
Column emp_id emp_name sex age income;
Run;
NOEXEC: Suppresses the building of the report
Proc report data=ds noexec;
Column emp_id emp_name sex age income;
Run;
SPLIT=’Any special character’: Split column labels into multiple lines.
Default split symbol in proc report is ‘/’
Proc report data= demo nowd split=’#’;
Column emp_id emp_name sex age income;
Define emp_id /display ‘Emp#ID’;
Define emp_name/display ‘Emp#Name’;
Define sex/display ‘Gender’ width=6;
Define age/display ‘Emp#Age’;
Define income/display ‘Emp#Earnings’;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
COLUMN statement
Select the variable which you want to prints in the report.
Default it selects all variables. Or use
_CHAR_ prints only Character variables.
Proc report data= demo nowd;
Column _char_;
Run;
_NUMERIC_ prints only numeric variables totals.
Proc report data= demo nowd;
Column _numeric_;
Run;
_ALL_ prints both char and numeric variables.
Proc report data= demo nowd;
Column _all_;
Run;
VAR1-VAR4 prints Var1 Var2 Var3 and Var4.
Proc report data= demo nowd;
Column var1-var4
Run;
VAR1- -VAR4 prints between Var1 and Var4 whatever variables are there.
Proc report data= demo nowd;
Column var1–var4
Run;
VAR: prints only which variables are starting with Var.
Proc report data= demo nowd;
Column var:;
Run;
DEFINE statement
It is useful to define variables.
Like applying attributes, alignment of columns and data, applying styles etc…
Define statement usually one for each column in the report,
Controls the appearance of the column,
Specifies how a variable is used in the report
Syntax:- DEFINE report-item / <usage> <option(s)>;
Define statement options
Column-header – Defines the column header for the report item. Enclose each header in single or double quotation marks. When you specify multiple column headers, PROC REPORT uses a separate line for each one. The split character also splits a column header over multiple lines.
FORMAT=format – assigns a SAS format or a user-defined format to the report item. This format applies to report-item as PROC REPORT displays it; the format does not alter the format associated with a variable in the data set.
WIDTH=column – width defines the width of the column in which PROC REPORT displays report-item.
SPACING= – Specify the number of blank characters between columns.
Default spacing=2.
ORDER=DATA | FORMATTED | FREQ | INTERNAL – orders the values of a GROUP, ORDER, or ACROSS variable according to the specified order, where
DATA orders values according to their order in the input data set.
FORMATTED orders values by their formatted (external) values. By default, the order is ascending.
FREQ orders values by ascending frequency count.
INTERNAL orders values by their unformatted values, which yields the same order that PROC SORT would yield. This order is operating environment dependent. This sort sequence is particularly useful for displaying dates chronologically.
Applying attributes like Label, Width and Format of variables.
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ order=data spacing=2;
Define emp_name/ ‘Emp Name’ spacing=2;
Define sex/ ‘Gender’ width=6 spacing=2;
Define age/ ‘Emp Age’ spacing=2;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
Applying alignment for variables and data.
Center – Center align for data values
Left – Left align for data values, default character variables values are left aligned.
Right – Right align for data values, default numeric variables values are left aligned.
style(column)={just=center | left | right} – Alignment for data values
style(header)={just=center | left | right} – Alignment for column headers, default is center
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ center ;
Define emp_name/ ‘Emp Name’ right;
Define sex/ ‘Gender’ width=6 right;
Define age/ ‘Emp Age’ left;
Define income/ ‘Emp Earnings’ format=comma12. center;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’
style(column)={just=center} style(header)={just=right};
Define emp_name/ ‘Emp Name’
style(column)={just=center} style(header)={just=right};
Define sex/ ‘Gender’ width=6
style(column)={just=center} style(header)={just=right};
Define age/ ‘Emp Age’
style(column)={just=center} style(header)={just=right};
Define income/ ‘Emp Earnings’ format=comma12.
style(column)={just=center} style(header)={just=right} ;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
Applying styles(colors) using define statement
Style={background=color} – Applying back ground color for column name and data.
Style={foreground=color} – Applying foreground color for column name and data.
Style={font_weight=bold} – Make font as bold.
Style={font_face=font name} – Change font type
Style={font_size=size of font} – Increase/decrease font_size.
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5};
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr};
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan};
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange};
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg};
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
Usage options in define statement
DISPLAY – Display data, default for character variables.
ORDER – Sort the rows and prints on each group wise.
GROUP – Consolidate observations into groups and removes if entire observation is duplicates.
ANALYSIS – Calculate a statistics, default for numeric variables.
COMPUTED – Computed by PROC REPORT
ACROSS – Class variables in the column dimension
PCTSUM – Finds individual contribution from overall observations.
DESCENDING – Reverses the order in which PROC REPORT displays rows or values of a
GROUP, ORDER, or ACROSS variable.
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
descending order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
BREAK AFTER statement
It is useful to print statistical calculations on each group or order variable wise for analysis variables. Or produces a default summary at a break (a change in the value of a GROUP or ORDER variable).
Syntax: – BREAK location break-variable </option(s)>;
Location controls the placement of the break lines, where location is
AFTER places the break lines immediately after the last row of each set(group) of rows that have the same value for the break variable.
BEFORE places the break lines immediately before the first row of each set(group) of rows that have the same value for the break variable.
Break-variable is a GROUP or ORDER variable. PROC REPORT writes break lines each time the value of this variable changes.
BREAK AFTER statement options
OL inserts a line of hyphens (-) above each value that appears in the summary line.
UL inserts a line of hyphens (-) under each value that appears in the summary line.
DOL inserts double line of hyphens (-) above each value that appears in the summary line.
DUL inserts double line of hyphens (-) above each value that appears in the summary line.
SKIP writes a blank line for the last break line.
SUMMARIZE writes a summary line in each group of break lines.
SUPPRESS suppresses the printing of the value of the break variable in the summary line, and of any underlining or overlining in the break lines.
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Break before sex/summarize ol ul style={background=violet};
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
Options missing=0;
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Break after sex/summarize skip dul dol style={background=violet}; /*without suppress*/
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
Options missing=0;
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Break after sex/summarize skip dul dol suppress style={background=violet};
/*with suppress*/
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
RBREAK AFTER statement
produces a default summary at the beginning or end of a report.
Syntax:- RBREAK location </option(s)>;
Location controls the placement of the break lines and is either
AFTER places the break lines at the end of the report.
BEFORE places the break lines at the beginning of the report.
RBREAK AFTER statement options
DOL specifies to double overline each value that appears in the summary line.
DUL specifies to double underline each value that appears in the summary line.
SKIP writes a blank line after the last break line of a break located at the beginning of the report.
SUMMARIZE includes a summary.
Options missing=0;
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Break after sex/summarize skip ul ol style={background=violet};
Rbreak after/summarize dul dol skip style={background=pink};
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
COMPUTE AFTER statement
Options missing=0;
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Break after sex/summarize skip ul ol style={background=violet};
Rbreak after/summarize dul dol skip style={background=pink};
Compute after;
emp_name=’Total’;
Endcomp;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
COMPUTE AFTER VARIABLE statement
Data demo;
length sex $12.;
format sex $12.;
Set demo;
Run;
Options missing=0;
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Break after sex/summarize skip ul ol style={background=violet};
Rbreak after/summarize dul dol skip style={background=pink};
Compute after;
sex=’Grand total’;
Endcomp;
Compute after sex;
sex=trim(sex)||’ – Total’;
Endcomp;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this’;
Run;
COMPUTE VARIABLE statement
Data demo;
length sex $20.;
format sex $20.;
Set demo;
Run;
Options missing=0;
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Break after sex/summarize skip ul ol style={background=violet};
Rbreak after/summarize dul dol skip style={background=pink};
Compute after;
sex=’Grand total’;
Endcomp;
Compute after sex;
sex=trim(sex)||’ – Total’;
Endcomp;
Compute sex;
If sex=’F’ then sex=’Female’;
If sex=’M’ then sex=’Male’;
Endcomp;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
CALL DEFINE
Data demo;
length sex $20.;
format sex $20.;
Set demo;
Run;
Options missing=0;
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Break after sex/summarize skip ul ol style={background=violet};
Rbreak after/summarize dul dol skip style={background=pink};
Compute after;
sex=’Grand total’;
Endcomp;
Compute after sex;
sex=trim(sex)||’ – Total’;
Endcomp;
Compute sex;
If sex=’F’ then sex=’Female’;
If sex=’M’ then sex=’Male’;
IF SEX=’Female’ then call define(_col_, ‘style’, ‘style={background=red}’);
IF SEX=’Male’ then call define(_col_, ‘style’, ‘style={background=yellow}’);
/*IF SEX=’Female’ then call define(_row_, ‘style’, ‘style={background=red}’);*/
/*IF SEX=’Male’ then call define(_row_, ‘style’, ‘style={background=yellow}’);*/
Endcomp;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
Data demo(drop=age rename=(x=age));
length sex $20.;
format sex $20.;
Set demo;
x=put(age,$10.);
Run;
Options missing=0;
Proc report data= demo nowd ;
Column emp_id emp_name sex age income;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Break after sex/summarize skip ul ol style={background=violet};
Rbreak after/summarize dul dol skip style={background=pink};
Compute after;
sex=’Grand total’;
Endcomp;
Compute after sex;
sex=trim(sex)||’ – Total’;
Endcomp;
Compute sex;
If sex=’F’ then sex=’Female’;
If sex=’M’ then sex=’Male’;
/*IF SEX=’Female’ then call define(_col_, ‘style’, ‘style={background=red}’);*/
/*IF SEX=’Male’ then call define(_col_, ‘style’, ‘style={background=yellow}’);*/
/*IF SEX=’Female’ then call define(_row_, ‘style’, ‘style={background=red}’);*/
/*IF SEX=’Male’ then call define(_row_, ‘style’, ‘style={background=yellow}’);*/
Endcomp;
Compute age;
If age <=20 then age =’Low-Age’;
Else if age <=40 then age =’Middle-Age’;
Else if age <=60 then age =’High-Age’;
If emp_id=. then age=’ ‘;
If age=’Low-Age’ then call define(_col_, ‘style’, ‘style={background=red}’);
If age=’Middle-Age’ then call define(_col_, ‘style’, ‘style={background=blue}’);
If age=’High-Age’ then call define(_col_, ‘style’, ‘style={background=green}’);
Endcomp;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;
Data demo(drop=age rename=(x=age));
length sex $20.;
format sex $20.;
Set demo;
x=put(age,$10.);
Run;
Options missing=0;
Proc report data= demo nowd ;
Column emp_id emp_name sex age income var1;
Define emp_id / ‘Emp ID’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=magenta foreground=blue font_weight=bold font_face=calibri font_size=5}
display;
Define emp_name/ ‘Emp Name’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=liolbr}
display;
Define sex/ ‘Gender’ width=6 spacing=2
style(column)={just=center} style(header)={just=right}
style={background=cyan}
group;
Define age/ ‘Emp Age’ spacing=2
style(column)={just=center} style(header)={just=right}
style={background=orange}
order;
Define income/ ‘Emp Earnings’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=bibg}
analysis;
Define var1/ ‘Income+Bonus’ format=comma12. spacing=2
style(column)={just=center} style(header)={just=right}
style={background=yellow}
computed;
Break after sex/summarize skip ul ol style={background=violet};
Rbreak after/summarize dul dol skip style={background=pink};
Compute after;
sex=’Grand total’;
Endcomp;
Compute after sex;
sex=trim(sex)||’ – Total’;
Endcomp;
Compute sex;
If sex=’F’ then sex=’Female’;
If sex=’M’ then sex=’Male’;
/*IF SEX=’Female’ then call define(_col_, ‘style’, ‘style={background=red}’);*/
/*IF SEX=’Male’ then call define(_col_, ‘style’, ‘style={background=yellow}’);*/
/*IF SEX=’Female’ then call define(_row_, ‘style’, ‘style={background=red}’);*/
/*IF SEX=’Male’ then call define(_row_, ‘style’, ‘style={background=yellow}’);*/
Endcomp;
Compute age;
If age <=20 then age =’Low-Age’;
Else if age <=40 then age =’Middle-Age’;
Else if age <=60 then age =’High-Age’;
If emp_id=. then age=’ ‘;
If age=’Low-Age’ then call define(_col_, ‘style’, ‘style={background=red}’);
If age=’Middle-Age’ then call define(_col_, ‘style’, ‘style={background=blue}’);
If age=’High-Age’ then call define(_col_, ‘style’, ‘style={background=green}’);
Endcomp;
Compute var1;
var1=income.sum+1000;
Endcomp;
Title ‘Emp Demographic Info ‘;
Title2 ‘Stansys Software Solutions’;
Footnote ‘This is a system generated mail please dont respond to this ‘;
Run;