Sample 25359: Using SYMPUT & SYMGET reporting
Sample on using CALL SYMPUT and SYMGET reporting.
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: DUSTY */
/* TITLE: Using SYMPUT & SYMGET Reporting */
/* PRODUCT: SAS */
/* SYSTEM: ALL */
/* KEYS: MACRO SYMPUT SYMGET */
/* PROCS: SUMMARY PRINT */
/* DATA: */
/* */
/* SUPPORT: UPDATE: */
/* REF: */
/* MISC: */
/* */
/****************************************************************/
DATA DUSTY;
INPUT DEPT $ NAME $ SALARY;
CARDS;
BEDDING WATLEE 18000
BEDDING PARKER 9000
BEDDING JOINER 8000
BEDDING IVES 16000
BEDDING GEORGE 8000
CARPET KARO 20000
CARPET RAY 12000
CARPET MCNAIR 10000
CARPET JONES 9000
CARPET THOMAS 12000
GIFTS RANKIN 7000
GIFTS MATTHEW 19000
KITCHEN BANKS 14000
KITCHEN WHITE 8000
KITCHEN MARKS 9000
KITCHEN CANNON 15000
TV SMITH 8000
TV JONES 9000
TV ROGERS 15000
TV MORSE 16000
;
PROC SUMMARY;
CLASS DEPT;
VAR SALARY;
OUTPUT OUT=STATS N=N_SAL MEAN=M_SAL SUM=S_SAL;
RUN;
PROC PRINT;
TITLE 'SUMMARY OF SALARY INFORMATION';
TITLE2 'FOR DUSTY DEPARTMENT STORE';
RUN;
DATA _NULL_;
SET STATS;
IF _N_=1 THEN DO;
CALL SYMPUT('S_TOT',S_SAL);
CALL SYMPUT('M_TOT',M_SAL);
END;
ELSE DO;
CALL SYMPUT('M'||DEPT,M_SAL);
CALL SYMPUT('S'||DEPT,S_SAL);
CALL SYMPUT('N'||DEPT,N_SAL);
END;
RUN;
DATA NEW;
SET DUSTY;
PCTDEPT=(SALARY / SYMGET('S'||DEPT)) * 100;
PCTTOT=(SALARY / SYMGET('S_TOT')) * 100;
DEPTMEAN=SYMGET('M'||DEPT);
NUM=SYMGET('N'||DEPT);
RUN;
PROC PRINT SPLIT='*';
LABEL PCTDEPT='PERCENT OF *DEPARTMENT'
PCTTOT='PERCENT OF * TOTAL'
DEPTMEAN='MEAN SALARY OF *DEPARTMENT';
TITLE 'SALARY PROFILES FOR EMPLOYEES';
TITLE2 'OF DUSTY DEPARTMENT STORE';
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.
SUMMARY OF SALARY INFORMATION
FOR DUSTY DEPARTMENT STORE
Obs DEPT _TYPE_ _FREQ_ N_SAL M_SAL S_SAL
1 0 20 20 12100 242000
2 BEDDING 1 5 5 11800 59000
3 CARPET 1 5 5 12600 63000
4 GIFTS 1 2 2 13000 26000
5 KITCHEN 1 4 4 11500 46000
6 TV 1 4 4 12000 48000
SALARY PROFILES FOR EMPLOYEES
OF DUSTY DEPARTMENT STORE
PERCENT OF PERCENT OF MEAN SALARY OF
Obs DEPT NAME SALARY DEPARTMENT TOTAL DEPARTMENT NUM
1 BEDDING WATLEE 18000 30.5085 7.43802 11800 5
2 BEDDING PARKER 9000 15.2542 3.71901 11800 5
3 BEDDING JOINER 8000 13.5593 3.30579 11800 5
4 BEDDING IVES 16000 27.1186 6.61157 11800 5
5 BEDDING GEORGE 8000 13.5593 3.30579 11800 5
6 CARPET KARO 20000 31.7460 8.26446 12600 5
7 CARPET RAY 12000 19.0476 4.95868 12600 5
8 CARPET MCNAIR 10000 15.8730 4.13223 12600 5
9 CARPET JONES 9000 14.2857 3.71901 12600 5
10 CARPET THOMAS 12000 19.0476 4.95868 12600 5
11 GIFTS RANKIN 7000 26.9231 2.89256 13000 2
12 GIFTS MATTHEW 19000 73.0769 7.85124 13000 2
13 KITCHEN BANKS 14000 30.4348 5.78512 11500 4
14 KITCHEN WHITE 8000 17.3913 3.30579 11500 4
15 KITCHEN MARKS 9000 19.5652 3.71901 11500 4
16 KITCHEN CANNON 15000 32.6087 6.19835 11500 4
17 TV SMITH 8000 16.6667 3.30579 12000 4
18 TV JONES 9000 18.7500 3.71901 12000 4
19 TV ROGERS 15000 31.2500 6.19835 12000 4
20 TV MORSE 16000 33.3333 6.61157 12000 4
This sample takes a summary dataset and uses CALL SYMPUT to create a different macro variable for each salary, mean and frequency count for each oberservation. The values of these macro variables are retrieved through SYMGET in order to do further calculations.
Type: | Sample |
Topic: | SAS Reference ==> Macro
|
Date Modified: | 2019-06-04 12:35:14 |
Date Created: | 2005-05-23 13:48:26 |
Operating System and Release Information
SAS System | Base SAS | All | n/a | n/a |