Proc Print :

This procedure prints out all or some of the variables in SAS dataset
And optionally prints out totals and subtotals for numeric variables.
Syntax:-
PROC PRINT <OPTIONS>;
VAR VARIABLE-LIST;
ID VARIABLE- LIST;
BY VARIABLE-LIST;
PAGE BY BY-VARIABLE;
SUM BY BY-VARIABLE;
SUM VARIABLE –LIST;
RUN;

Examples:-
Prints recent created dataset.
PROC PRINT;
RUN;
Options:-
Data=dataset – Specify sas dataset name which you are printing.
Otherwise it prints recent created dataset.
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA;
RUN;
Noobs – Suppresses printing of obs column.
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA NOOBS;
RUN;
Obs = Name – Assigns a name for Obs column
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA OBS=’Stansys’;
RUN;
Heading=Vertical – Prints Column names vertically in output default is horizontal.
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA OBS=’Stansys’ HEADING=VERTICAL;
RUN;
Double – Write a blank line between observations
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE;
RUN;

Blankline= Write a blank line after n observations
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA NOOBS BLANKLINE=5;
RUN;
N – Prints no of observations.
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N;
RUN;
Label – Variable labels as column headings.
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N LABEL;
LABEL SEX=GENDER INCOME=SALARY;
RUN;
Sumlabel – Display the BY variable label on the summary line
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA NOOBS LABEL SUMLABEL;
LABEL SEX=GENDER INCOME=SALARY;
BY ZONE;
RUN;
Spilt – The label for variables is split across multiple lines
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’;
LABEL SEX=GENDER
INCOME=SALARY
EMP_ID=EMPLOYEE*ID
EMP_NAME=EMPLOYEE*NAME;
RUN;
Uniform – Formats all pages uniformly.
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM;
LABEL SEX=GENDER
INCOME=SALARY
EMP_ID=EMPLOYEE*ID
EMP_NAME=EMPLOYEE*NAME;
RUN;
Width= column-width
Determines the column width for each variable. The value of column-width must be one of the following:

FULL 
Uses a variable’s formatted width as the column width. If the variable does not have a format that explicitly specifies a field width, PROC PRINT uses the default width. For a character variable, the default width is the length of the variable. For a numeric variable, the default width is 12. When you use WIDTH=FULL, the column widths do not vary from page to page.
MINIMUM 
Uses for each variable the minimum column width that accommodates all values of the variable.
UNIFORM 
Uses each variable’s formatted width as its column width on all pages. If the variable does not have a format that explicitly specifies a field width, PROC PRINT uses the widest data value as the column width. When you specify WIDTH=UNIFORM, PROC PRINT normally needs to read the data set twice. However, if all the variables in the data set have formats that explicitly specify a field width (for example, BEST12. but not BEST.), PROC PRINT reads the data set only once.
UNIFORMBY 
Formats all columns uniformly within a BY group, using each variable’s formatted width as its column width. If the variable does not have a format that explicitly specifies a field width, PROC PRINT uses the widest data value as the column width.
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA NOOBS WIDTH=FULL
RUN;
Round – Round unformatted numeric values to two decimal places. 
PROC PRINT DATA= My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N 
                        LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL SEX=GENDER 
             INCOME=SALARY
EMP_ID=EMPLOYEE*ID
            EMP_NAME=EMPLOYEE*NAME;
RUN;
 
STYLE <(location(s))>=<style-element-name><[style-attribute-specification(s)]> 
Style – Specify one or more style elements for the Output Delivery System to use for different parts of the report.
You can use braces ({ and }) instead of square brackets ([ and ]).
Location – Identifies the part of the report that the STYLE option affects. 
The following table shows the available locations and the other statements in which you can specify them.
screenshot 2025 09 23 191622

Style-element-name – Is the name of a style element that is part of a style definition that is registered with the Output Delivery System. SAS provides some style definitions. Users can create their own style definitions with PROC TEMPLATE.
When style elements are processed, more specific style elements override less specific style elements.

screenshot 2025 09 23 191846

Style-attribute-specification
Describes the style attribute to change. Each style-attribute-specification has this general form: style-attribute-name=style-attribute-value
You can set these following style attributes in the TABLE location:
BACKGROUNDCOLOR=                FONTWIDTH=*             BACKGROUNDIMAG=

COLOR=*                                      BORDERCOLOR=          FRAME=
BORDERCOLORDARK=                 HTMLCLASS=               BORDERCOLORLIGHT= 

TEXTALIGN=                                 BORDERWIDTH=           OUTPUTWIDTH=
CELLPADDING=                            POSTHTML=                 CELLSPACING=

POSTIMAGE=                               FONT=*                          POSTTEXT=
FONTFAMILY=*                            PREHTML=                     FONTSIZE=*

PREIMAGE=                                 FONTSTYLE=*                 PRETEXT=
FONTWEIGHT=*                          RULES=

* When you use these attributes, they affect only the text that is specified with the PRETEXT=, POSTTEXT=, PREHTML=, and POSTHTML= attributes.

To alter the foreground color or the font for the text that appears in the table, you must set the corresponding attribute in a location that affects the cells rather than the table.
You can set these style attributes in all locations other than TABLE:
ASIS=                             FONTWIDTH=                           BACKGROUNDCOLOR=

HREFTARGET=               BACKGROUNDIMAGE=             CLASS=
BORDERCOLOR=           TEXTALIGN=                             BORDERCOLORDARK=
NOBREAKSPACE=          BORDERCOLORLIGHT=            POSTHTML=
BORDERWIDTH=           POSTIMAGE=                           HEIGHT=
POSTTEXT=                   CELLWIDTH=                            PREHTML=
FLYOVER=                     PREIMAGE=                              FONT=
PRETEXT=                     FONTFAMILY=                          PROTECTSPECIALCHARS=

FONTSIZE=                  TAGATTR=                                 FONTSTYLE=
URL=                            FONTWEIGHT=                        VERTICALALIGN=

Statements with Options
Var Statement: – To select the variables which we required into output
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX INCOME;
RUN;
Where Statement: – Select data into output based on condition
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX INCOME;
WHERE SEX=’M’;
/*WHERE SEX=’F’;*/
RUN;

ID Statement: – ID variable comes the position of OBS place.
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX INCOME;
ID ZONE;
RUN;

After remove ZONE from VAR statement.
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX INCOME;
ID ZONE;
RUN;

BY Statement: – Prints data separately on each group of BY variable.
Where ever we are using by statement, it should be in sorting order
PROC SORT DATA=My_SAS.DEMOGRAPHIC_DATA;
BY ZONE;
RUN;
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX INCOME;
BY ZONE;
RUN;
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX INCOME;
ID ZONE;
BY ZONE;
RUN;

PAGEBY Statement: – Prints data separately on each group of BY variable in Separate page.
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX INCOME;
BY ZONE;
PAGEBY ZONE;
RUN;

SUMBY Statement: – Prints subtotals and totals for all the numeric variables,
Prints subtotals based on each group of BY variable
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX AGE INCOME;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
RUN;

SUM Statement: – Prints subtotals and totals for specific numeric variables
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX AGE INCOME;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
RUN;

TITLE: – Assigns title for the report, generally it should be in top of the report
The default title is SAS SYSTEM
It is a global option, u can write anywhere in the program
Maximum we can write 10 titles.
FOOTNOTE: – Assigns footnote for the report, generally it should be bottom of the report
It is a global option, u can write anywhere in the program
Maximum we can write 10 footnotes.
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX AGE INCOME;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title ‘ Employee Demographic Data’;
Title2 ‘Stansys Software Solutions ‘;
Footnote ‘Generated By Mr. Krishna ‘;
RUN;
Options Titles & Footnotes
Justify=Left/Right (or) Justify=L/R (or) J=Left/Right (or) J=L/R
Justify left/right alignment of Titles and Footnotes. Default is center aligned.
Color=Color name (or) C=Color name
Applies color for Titles and Footnotes.
Font=Font name (or) F=Font
Applies font name for Titles and Footnotes.
Height=Height size (or) H= Height size
Applies size of letters for Titles and Footnotes.
Bold/Italic
Titles and Footnotes letters will become bold/italic.

PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX AGE INCOME;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title j=l c=red f=Arial h=7 ‘ Employee Demographic Data’;
Title2 j=r c=blue f=Arial h=6 ‘Stansys Software Solutions ‘;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;

To remove Titles and Footnotes
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX AGE INCOME;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title ‘ ‘;
Title2;
Footnote;
RUN;
Applying styles in proc print
PROC FORMAT;
VALUE $val ‘F’=’RED’
‘M’=’GREEN’;
RUN;
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME INCOME SEX/style=[foreground=$val.] ;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title j=l c=red f=Arial h=7 ‘ Employee Demographic Data’;
Title2 j=r c=blue f=Arial h=6 ‘Stansys Software Solutions ‘;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;

Converting Report into user format HTML
ODS HTML
FILE=”C:\Documents and Settings\Neeru\Desktop\Reports\Demographic.html”;
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME INCOME SEX/style=[background=$val.] ;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title c=red f=Arial h=7 ‘ Employee Demographic Data’;
Title2 c=red f=Arial h=7 ‘Neeru Technologies ‘;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;
ODS HTML CLOSE;

Converting Report into user format Pdf
ODS PDF
FILE=”C:\Documents and Settings\Neeru\Desktop\Reports\Demographic.PDF” NOTOC;
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME INCOME SEX/style=[foreground=$val.] ;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title c=red f=Arial h=7 ‘ Employee Demographic Data’;
Title2 c=red f=Arial h=7 ‘Neeru Technologies ‘;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;
ODS PDF CLOSE;

Converting Report into user format Excel
ODS tagsets.excelxp
FILE=”C:\Documents and Settings\Neeru\Desktop\Reports\Demographic.xls” ;
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME INCOME SEX/style=[foreground=$val.] ;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title c=red f=Arial h=7 ‘ Employee Demographic Data’;
Title2 c=red f=Arial h=7 ‘Neeru Technologies ‘;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;
ODS tagsets.excelxp CLOSE;

Customizing PROC PRINT Output with the STYLE= Option
We can use different styles to change overall look of any output which produce thru proc print, proc report & proc tabulate by using STYLE=OPTION in proc step.
Syntax:- PROC PRINT STYLE(location-list) = {style-attribute = value};
Location – List like
DATA (all the data cells)
HEADER ( the column headers (variable names))
OBS (the data in the OBS column, or ID column if using an ID statement)
OBSHEADER (the header for the OBS or ID column)
TOTAL (the data in the totals row produced by a SUM statement)
GRANDTOTAL (the data for the grand total produced by a SUM statement)
Example:-
DATA DS;
SET SASHELP.CLASS;
RUN;
PROC SORT DATA=DS;
BY SEX;
RUN;
ODS HTML FILE=”C:\Documents and Settings\Administrator\Desktop\sas\Demo.htm”;
PROC PRINT STYLE(DATA) = {BACKGROUND = pink};
/*PROC PRINT STYLE(HEADER) = {BACKGROUND = pink};*/
/*PROC PRINT STYLE(OBS) = {BACKGROUND = pink};*/
/*PROC PRINT STYLE(OBSHEADER) = {BACKGROUND = pink};*/
/*PROC PRINT STYLE(TOTAL) = {BACKGROUND = pink};*/
/*PROC PRINT STYLE(GRANDTOTAL) = {BACKGROUND = pink};*/
PROC PRINT DATA=DS NOOBS;
VAR NAME SEX AGE HEIGHT WEIGHT;
BY SEX;
SUMBY SEX;
SUM HEIGHT WEIGHT;
Title c=red f=Arial h=7 ‘ Student Data’;
Title2 c=red f=Arial h=7 ‘Stansys Software Solutions’;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;
ODS HTML CLOSE;
In above example style is applying for entire table(for all variables one style)
But if you want to apply different styles for different variables see below program.
Syntax:-VAR variable / STYLE(location-list) = {style-attribute = value};

ODS HTML FILE=”C:\Documents and Settings\Administrator\Desktop\sas\DEMO.HTM”;
PROC PRINT DATA=DS NOOBS;
VAR NAME/STYLE(DATA)={BACKGROUND=RED FOREGROUND=YELLOW} ;
VAR SEX ;
VAR AGE ;
VAR HEIGHT ;
VAR WEIGHT;
BY SEX;
SUMBY SEX;
SUM HEIGHT WEIGHT;
Title c=red f=Arial h=7 ‘ Student Data’;
Title2 c=red f=Arial h=7 ‘Stansys Software Solutions’;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;
ODS HTML CLOSE;

ODS HTML FILE=”C:\Documents and Settings\Administrator\Desktop\mysas\DEMO.HTM”;
PROC PRINT DATA=DS NOOBS;
VAR NAME/STYLE(DATA)={BACKGROUND=yellow FOREGROUND=RED} ;
VAR SEX /STYLE(HEADER)={BACKGROUND=CYAN} ;
VAR AGE /STYLE(DATA)={BACKGROUND=orange FOREGROUND=BLUE} ;
VAR HEIGHT /STYLE(DATA)={BACKGROUND=GWH } ;
VAR WEIGHT/STYLE(HEADER)={BACKGROUND=MAGENTA} ;
BY SEX;
SUMBY SEX;
SUM HEIGHT WEIGHT;
Title c=red f=Arial h=7 ‘ Student Data’;
Title2 c=red f=Arial h=7 ‘Stansys Software Solutions’;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;
ODS HTML CLOSE;

Using Macros in Proc Print
%global repdate;
Proc sql;
Connect to oracle as Krishna (USER=Stanmis PASSWORD=”{sas001}QzBycDByX3Qz”
PATH=demprod);
Create table repo as
Select * from connection to Krishna
(
Select to_char(to_date(sysdate-1),’dd-Mon-yyyy’) as repdate from dual
);
Disconnect from Krishna;
Quit;
Data _null_;
Set repo;
kx=repdate;
Call symput(‘repdate’,kx);
Put kx ;
Run;
PROC IMPORT
DATAFILE=”C:\Documents and Settings\Stan\Desktop\Demographic_data.csv”
OUT=My_SAS.DEMOGRAPHIC_DATA DBMS=CSV REPLACE;
RUN;
PROC SORT DFATA= My_SAS.DEMOGRAPHIC_DATA;
BY ZONE;
RUN;
PROC FORMAT LIB=My_SAS;
VALUE $GEN ‘F’=’RED’
‘M’=’GREEN’;
RUN;
ODS PDF
FILE=”C:\Documents and Settings\Stan\Desktop\Reports\Demographic.PDF” NOTOC;
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR REGION REGIONAL_MANAGER EMP_NAME INCOME SEX/style=[background=$GEN.];
ID ZONE ZONAL_HEAD;
BY ZONE ZONAL_HEAD;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title c=red f=Arial h=7 ‘ Employee Demographic Data’;
Title2 c=red f=Arial h=7 ‘Stansys Software Solutions’;
Footnote j=l c=green f=’comic sans ms’ h=7 “Generated by Mr. Krishna on &repdate”;
RUN;
ODS PDF CLOSE;

Delivering thru Mail
Filename Demo EMAIL
Sender=”MIS@stansys.co.in”
From= (“MIS@stansys.co.in”)
To= (“Charan@stansys.co.in”
“Narayan@stansys.co.in”
“Venkat@stansys.co.in”
)
Cc= (
“Ashish.Kehair@stansys.co.in”
“dharmesh.dixit@stansys.co.in”
“ketan.karkhanis@stansys.co.in”
“mihir.mehta@stansys.co.in”
“chirag.shah@stansys.co.in”
“priti.shah@stansys.co.in”
)
Bcc= (
“krishna@stansys.co.in”
“jatin.motwani@stansys.co.in”
“ankit.sharma@stansys.co.in”
)
Subject= “Demographic Report as on &repdate”
Type=”text/html”;
Ods listing close;
ODS HTML BODY=Demo style=seaside
Base=’/sas/sasebi/apache/htdocs/SBTG/’
Rs=none;
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME SEX INCOME;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title c=red f=Arial h=7 ‘ Employee Demographic Data’;
Title2 c=red f=Arial h=7 ‘Stan Software Solutions ‘;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;
ODS HTML CLOSE;
Scheduling Report thru Base SAS
Write a program in SAS window like below and save in your SAS
Server or Local pc in particular location
Ex: – (E:\SAS_SCHEDULE\Demographic.sas)
———————————————————————————————-
Deliver the report into ODS location through scheduling
———————————————————————————————-
PROC IMPORT
DATAFILE=”C:\Documents and Settings\Stan\Desktop\Demographic_data.csv”
OUT=My_SAS.DEMOGRAPHIC_DATA DBMS=CSV REPLACE;
GETNAMES=YES;
RUN;
PROC SORT DFATA= My_SAS.DEMOGRAPHIC_DATA;
BY ZONE;
RUN;
PROC FORMAT;
VALUE $val ‘F’=’RED’
‘M’=’GREEN’;
RUN;
ODS PDF FILE=”C:\Documents and Settings\Stan\Desktop\Reports\Demographic.PDF” NOTOC;
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N
LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
REGIONAL_MANAGER = REGIONAL*MANAGER
EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME INCOME SEX/style=[background=$val.] ;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title c=red f=Arial h=7 ‘ Employee Demographic Data’;
Title2 c=red f=Arial h=7 ‘Stan Software Solutions ‘;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;
ODS PDF CLOSE;

———————————————————————————————-
Deliver the report to user mail id through scheduling
———————————————————————————————-
PROC IMPORT 
DATAFILE=”C:\Documents and Settings\Stan\Desktop\Demographic_data.csv”
OUT=My_SAS.DEMOGRAPHIC_DATA DBMS=CSV REPLACE;
GETNAMES=YES;
RUN;
PROC SORT DATA= My_SAS.DEMOGRAPHIC_DATA;
BY ZONE;
RUN;
PROC FORMAT;
VALUE $val ‘F’=’RED’
                     ‘M’=’GREEN’;
RUN;
Filename Demo EMAIL
Sender=”MIS@stansys.co.in”
From= (“MIS@stansys.co.in”)
To= (
         “Charan@stansys.co.in”
          “Narayan@stansys.co.in”
          “Venkat@stansys.co.in” 
        )
Cc= (
         “Ashish.Kehair@stansys.co.in”
         “dharmesh.dixit@stansys.co.in” 
         “ketan.karkhanis@stansys.co.in”  
         )
 Bcc= (
           “radhakrishna@stansys.co.in”     
           “rajesh.si@stansys.co.in”
          )
Subject= “Demographic Report as on &sysdate9”
Type=”text/html”;
Ods listing close;
ODS HTML BODY=Demo style=seaside 
Base=’/sas/sasebi/apache/htdocs/SBTG/’ 
Rs=none;
 
 
PROC PRINT DATA=My_SAS.DEMOGRAPHIC_DATA NOOBS DOUBLE N 
                                LABEL SPLIT=’*’ UNIFORM ROUND;
LABEL ZONAL_HEAD=ZONAL*MANAGER
          REGIONAL_MANAGER = REGIONAL*MANAGER
          EMP_NAME=EMPLOYEE*NAME;
VAR ZONE ZONAL_HEAD REGION REGIONAL_MANAGER EMP_NAME INCOME SEX/style=[background=$val.] ;
BY ZONE;
PAGEBY ZONE;
SUMBY ZONE;
SUM INCOME;
Title c=red f=Arial h=7 ‘ Employee Demographic Data’;
Title2 c=red f=Arial h=7 ‘Stan Software Solutions ‘;
Footnote j=l c=green f=’comic sans ms’ h=7 ‘Generated by Mr. Krishna ‘;
RUN;
ODS HTML CLOSE;
 
Click Start select SAS9.2 (English). 
Right click on SAS9.2 (English) Select Properties.
Click on Properties and choose Target location
 Target location is like below
“C:\Program Files\SAS\SASFoundation\9.2\sas.exe” 
-CONFIG 
“C:\Program Files\SAS\SASFoundation\9.2\nls\en\SASV9.CFG”
But select Upto sas.exe like below
“C:\Program Files\SAS\SASFoundation\9.2\sas.exe” 
Copy above location into notepad and add program location like
“C:\Program Files\SAS\SASFoundation\9.2\sas.exe” 
-sysin E:\SAS_SCHEDULE \Demographic.sas
 Exit;
Save above code (Notepad) with filename.bat like
Demographic.bat
A batch file is created now 
Right click on batch file and click open for execution
SAS program executes (E:\SAS_SCHEDULE\Demographic.sas)
and creates a report into ODS location.
Adding Schedule Timings   
Click Start -> All Programs -> Accessories -> System Tools -> 
Scheduled Tasks -> Add Scheduled Task 
Click on Add Scheduled Task Click next and browse the location of 
Batch file and select any one perform task.
Performs tasks are
Daily
Weekly
Monthly
One time only
When my computer starts
When I log on
 
Ex:- Click Daily -> next -> Select the Time and Day you want this task to start like 10:00 am Everyday
Click next Enter the password and Confirm the password
Click next Click Finish.
Every day morning 10:00 batch file executes and send the report into ODS location.
 
A small real time Report with Proc print
%Global Repdate;
PROC SQL;
Connect to ODBC (DATASRC=StanIQ USER=StanMIS PASSWORD=”{sas001}aXNlY21pc0AxMjM=”);
Create table dat11 as
Select * from connection to ODBC
(
Select dateformat(getdate()-1,’DD-Mmm-YYYY’) as Repdate
);
Disconnect from ODBC;
Quit;
Data _null_;
Set dat11;
ka=repdate;
Call symput(‘Repdate’,ka);
Put ka;
Run;
PROC SQL;
Connect to ODBC(DATASRC=StanIQ USER=StanMIS PASSWORD=”{sas001}aXNlY21pc0AxMjM=”);
Create table One as
Select * from connection to ODBC
(
SELECT * FROM V_ETL_STATUS_LOG
WHERE START_DTTM >= DATEFORMAT(GETDATE()-1, ‘YYYY-MM-DD 18:00:00’)
AND END_DTTM <= DATEFORMAT(GETDATE(), ‘YYYY-MM-DD 08:00:00’)
AND JOB_NAME LIKE ‘P_LOAD%’
ORDER BY START_DTTM ASC
);
Disconnect from ODBC;
Quit;
PROC SQL;
Connect to ODBC(DATASRC=StanIQ USER=StanMIS PASSWORD=”{sas001}aXNlY21pc0AxMjM=”);
Create table two as
Select * from connection to ODBC
(
SELECT * FROM V_ETL_STATUS_LOG
WHERE START_DTTM >= DATEFORMAT(GETDATE()-1, ‘YYYY-MM-DD 18:00:00’)
AND END_DTTM <= DATEFORMAT(GETDATE(), ‘YYYY-MM-DD 08:00:00’)
AND JOB_NAME NOT LIKE ‘P_LOAD%’
ORDER BY START_DTTM ASC
);
Disconnect from ODBC;
Quit;
 
Proc format;
Value $vol ‘Failed’=’red’
       ‘Success’=’Green’
       ‘Warning’=’Orange’;
Run;
Filename ETL EMAIL
Sender=”MIS@stansys.co.in”
From= (“MIS@stansys.co.in”)
To= (“Ramesh@stansys.co.in” “krishna@stansys.co.in”)
Subject= “Sybase IQ :: ETL Status as on &repdate”
Type=”text/html”;
Ods listing close;
ODS HTML BODY=ETL style=seaside
Base=’/sas/sasebi/apache/htdocs/SBTG/’ 
Rs=none;
OPTIONS MISSING=0;
Proc print data=one label split=’*’;
FORMAT TARGET_COUNT comma30. ;
Var JOB_NAME OBJECT_NAME START_DTTM END_DTTM DURATION SOURCE_COUNT TARGET_COUNT STATUS/style=[foreground=$vol.];
 
Label JOB_NAME=’Job Name’
        OBJECT_NAME=’Object Name’
        START_DTTM=’Start Date’
        END_DTTM=’End Date’
        DURATION=’Duration*(In Sec)’
        SOURCE_COUNT=’Source*Count’
        TARGET_COUNT=’Target*Count’
        STATUS=’Status’;
Title “Status of Staging Jobs as on &repdate”;
Footnote;
Run;
Proc print data=two label split=’*’;
FORMAT SOURCE_COUNT comma30. TARGET_COUNT comma30. ;
Var JOB_NAME OBJECT_NAME START_DTTM END_DTTM DURATION SOURCE_COUNT TARGET_COUNT STATUS/style=[foreground=$vol.];
Label JOB_NAME=’Job Name’
        OBJECT_NAME=’Object Name’
        START_DTTM=’Start Date’
        END_DTTM=’End Date’
        DURATION=’Duration*(In Sec)’
        SOURCE_COUNT=’Source*Count’
        TARGET_COUNT=’Target*Count’
        STATUS=’Status’;
Title “Status of Transformation Jobs as on &repdate”;
Footnote “Note: This is a system generated mail. Please do not respond to this mail.”;
Run;
ODS html close;