Sample 25426: Payroll report writing using PUT statement
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
This sample is from the SAS Sample Library. For additional information refer to SAS Help and Online Documentation.
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: REPORT2 */
/* TITLE: Payroll Report Writing Using PUT Statement */
/* PRODUCT: SAS */
/* SYSTEM: ALL */
/* KEYS: REPO DATASTEP SORT COLON : FORMAT MODIFIER INPUT */
/* SET BY FIRST. LAST. FILE PUT LINESLEFT HEADER */
/* SUM RETAIN */
/* PROCS: SORT */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: */
/* MISC: */
/* */
/****************************************************************/
DATA PAYROLL;
INPUT DEPT NAME :$20. NUMBER SEX $ NETPAY :6.2 GROSSPAY : 6.2;
CARDS;
911 HAFER 9764 F 9664 12195
911 YOUNG 4589 M 22969 31360
911 REYNOLDS 5805 F 13403 17415
911 STRIDE 3890 M 27253 38340
911 ISSAC 12641 M 21991 31360
911 GREEN 12829 M 23804 36560
911 SMOTHERS 1782 M 20243 31520
911 KRAUSE 3571 F 18209 24240
911 POST 455 M 20660 29200
911 POWELL 11710 M 16753 24395
914 LARSON 11357 F 21547 28392
914 ARNOLD 1956 M 35687 44550
914 MANHART 11602 M 25034 34478
914 VETTER 1895 M 18928 27936
914 CURCI 8262 M 21531 37600
914 GRECO 7231 M 68523 100400
914 RYAN 10961 M 29156 39920
914 JOHNSON 10546 M 13523 18072
914 THOMSPON 11584 M 22109 29756
915 CORNING 2688 F 10343 14616
915 WOOD 8113 F 23817 37224
915 GREEN 5276 M 72516 112451
915 HAYDEN 6843 F 10354 14631
915 TAYLOR 2943 F 28722 40172
915 CHAPMAN 3624 M 26431 38547
915 ROCHE 6781 M 28737 40212
915 MOORE 12649 M 55718 72812
915 HELMS 3658 M 47926 70126
916 FARLOW 10349 M 52719 84203
916 SHIRES 10052 F 18712 27922
916 RICHARDS 5781 M 21927 35284
916 SMITH 6237 F 14709 20188
916 MURPHY 6927 M 27266 38511
916 FAIRLEY 8846 M 52166 83480
917 HERZOG 6433 M 69257 104526
917 TALL 11931 M 35519 49226
917 HIGGINS 11658 M 77750 123546
917 MCKAY 10155 M 82144 139227
917 SANFORD 12649 F 28406 40537
917 DOOB 10554 F 16906 27229
918 BRANDON 2200 M 55431 80464
918 EPERT 7716 M 22436 31040
918 CLANCY 6648 M 24537 34712
918 POWELL 8123 F 18939 27154
940 HICKS 15497 M 55387 80731
940 VANCE 1576 M 48703 78900
940 CARTER 1333 M 71289 115822
;
PROC SORT;
BY DEPT;
RUN;
DATA _NULL_;
SET PAYROLL END=EOF;
BY DEPT;
FILE PRINT HEADER=H LINESLEFT=LL NOTITLES;
IF FIRST.DEPT THEN DO;
NETTOT = 0; GROSSTOT = 0;
IF LL < 14 THEN PUT _PAGE_;
END;
PUT @4 DEPT 3. @14 NAME $20. @36 NUMBER 5. @46 SEX $1.
@52 NETPAY 6.2 @63 GROSSPAY 7.2;
NETTOT + NETPAY; GROSSTOT + GROSSPAY;
IF LAST.DEPT THEN DO;
PUT @51 '-------' @63 '-------'
/ 'DEPARTMENT TOTAL' @48 NETTOT DOLLAR10.2
@60 GROSSTOT DOLLAR10.2 //;
GRANDNET + NETTOT; GRANDGRO + GROSSTOT;
END;
IF EOF THEN
PUT 'OVERALL TOTAL' @48 GRANDNET DOLLAR10.2
@60 GRANDGRO DOLLAR10.2;
RETURN;
H: PUT // @22 'ABC MANUFACTURING COMPANY' / @28 'PAYROLL REPORT'
/// @20 'EMPLOYEE' @35 'EMPLOYEE' @52 'NET' @63 'GROSS'
/ 'DEPARTMENT' @22 'NAME' @36 'NUMBER' @45 'SEX'
@52 'PAY' @64 'PAY' //;
RETURN;
RUN;
/* A multicolumn listing using N=PS. */
PROC SORT;
BY NAME;
RUN;
OPTIONS LS=64 NODATE;
DATA _NULL_;
TITLE 'EMPLOYEE DIRECTORY';
TITLE3 ;
SET PAYROLL;
FILE PRINT N=PS;
RETAIN L 1 C 1;
PUT #L @C NAME $20. + 1 DEPT 5.;
L + 1;
IF L <=25 THEN RETURN;
C + 30; L = 1;
IF C < 62 THEN RETURN;
PUT _PAGE_;
C = 1;
RUN;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
ABC MANUFACTURING COMPANY
PAYROLL REPORT
EMPLOYEE EMPLOYEE NET GROSS
DEPARTMENT NAME NUMBER SEX PAY PAY
911 HAFER 9764 F 96.64 121.95
911 YOUNG 4589 M 229.69 313.60
911 REYNOLDS 5805 F 134.03 174.15
911 STRIDE 3890 M 272.53 383.40
911 ISSAC 12641 M 219.91 313.60
911 GREEN 12829 M 238.04 365.60
911 SMOTHERS 1782 M 202.43 315.20
911 KRAUSE 3571 F 182.09 242.40
911 POST 455 M 206.60 292.00
911 POWELL 11710 M 167.53 243.95
------- -------
DEPARTMENT TOTAL $1,949.49 $2,765.85
914 LARSON 11357 F 215.47 283.92
914 ARNOLD 1956 M 356.87 445.50
914 MANHART 11602 M 250.34 344.78
914 VETTER 1895 M 189.28 279.36
914 CURCI 8262 M 215.31 376.00
914 GRECO 7231 M 685.23 1004.00
914 RYAN 10961 M 291.56 399.20
914 JOHNSON 10546 M 135.23 180.72
914 THOMSPON 11584 M 221.09 297.56
------- -------
DEPARTMENT TOTAL $2,560.38 $3,611.04
915 CORNING 2688 F 103.43 146.16
915 WOOD 8113 F 238.17 372.24
915 GREEN 5276 M 725.16 1124.51
915 HAYDEN 6843 F 103.54 146.31
915 TAYLOR 2943 F 287.22 401.72
915 CHAPMAN 3624 M 264.31 385.47
915 ROCHE 6781 M 287.37 402.12
915 MOORE 12649 M 557.18 728.12
915 HELMS 3658 M 479.26 701.26
------- -------
DEPARTMENT TOTAL $3,045.64 $4,407.91
ABC MANUFACTURING COMPANY
PAYROLL REPORT
EMPLOYEE EMPLOYEE NET GROSS
DEPARTMENT NAME NUMBER SEX PAY PAY
916 FARLOW 10349 M 527.19 842.03
916 SHIRES 10052 F 187.12 279.22
916 RICHARDS 5781 M 219.27 352.84
916 SMITH 6237 F 147.09 201.88
916 MURPHY 6927 M 272.66 385.11
916 FAIRLEY 8846 M 521.66 834.80
------- -------
DEPARTMENT TOTAL $1,874.99 $2,895.88
917 HERZOG 6433 M 692.57 1045.26
917 TALL 11931 M 355.19 492.26
917 HIGGINS 11658 M 777.50 1235.46
917 MCKAY 10155 M 821.44 1392.27
917 SANFORD 12649 F 284.06 405.37
917 DOOB 10554 F 169.06 272.29
------- -------
DEPARTMENT TOTAL $3,099.82 $4,842.91
918 BRANDON 2200 M 554.31 804.64
918 EPERT 7716 M 224.36 310.40
918 CLANCY 6648 M 245.37 347.12
918 POWELL 8123 F 189.39 271.54
------- -------
DEPARTMENT TOTAL $1,213.43 $1,733.70
940 HICKS 15497 M 553.87 807.31
940 VANCE 1576 M 487.03 789.00
940 CARTER 1333 M 712.89 1158.22
------- -------
DEPARTMENT TOTAL $1,753.79 $2,754.53
OVERALL TOTAL $15,497.54 $23,011.82
EMPLOYEE DIRECTORY
ARNOLD 914 MCKAY 917
BRANDON 918 MOORE 915
CARTER 940 MURPHY 916
CHAPMAN 915 POST 911
CLANCY 918 POWELL 911
CORNING 915 POWELL 918
CURCI 914 REYNOLDS 911
DOOB 917 RICHARDS 916
EPERT 918 ROCHE 915
FAIRLEY 916 RYAN 914
FARLOW 916 SANFORD 917
GRECO 914 SHIRES 916
GREEN 911 SMITH 916
GREEN 915 SMOTHERS 911
HAFER 911 STRIDE 911
HAYDEN 915 TALL 917
HELMS 915 TAYLOR 915
HERZOG 917 THOMSPON 914
HICKS 940 VANCE 940
HIGGINS 917 VETTER 914
ISSAC 911 WOOD 915
JOHNSON 914 YOUNG 911
KRAUSE 911
LARSON 914
MANHART 914
This example demonstrates how to write payroll report using PUT statement.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step Query and Reporting ==> Creating Reports ==> Non Graphical
|
| Date Modified: | 2005-12-08 11:34:45 |
| Date Created: | 2005-05-23 13:52:58 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |