Sunteți pe pagina 1din 24

/*

/*
/*
/*
/*
/*

Example 1 - Convert all numeric missing values to zero.

*/
*/
Use the ARRAY statement with the automatic _NUMERIC_ variable to */
process all the numeric variables from the input data set. Use
*/
the DIM function to set the upper bound of an iterative DO to the */
number of elements in the array.
*/

/* Create sample data */


data numbers;
input var1 var2 var3;
datalines;
7 1 4
. 0 8
9 9 .
5 6 2
8 3 0
;
data nomiss(drop=i);
set numbers;
array testmiss(*) _numeric_;
do i = 1 to dim(testmiss);
if testmiss(i)=. then testmiss(i)=0;
end;
run;
proc print;
run;
/*
Example 2 -- Convert selected numeric values from zero to missing.
*/
/*
*/
/*
Use the ARRAY statement to define the specific numeric variables
to
*/
/*
change from a value of zero to a missing value. Use the DIM
function */
/*
to set the upper bound of an iterative DO to the number of
elements in */
/*
the array.
*/
data deptnum;
input dept qrt1 qrt2 qrt3 qrt4;
datalines;
101 3 0 4 9
410 8 7 5 8
600 0 0 6 7
700 6 5 6 9
901 3 8 7 0
;
data nozero(drop=i);
set deptnum;
array testzero(*) qrt1-qrt4;

do i = 1 to dim(testzero);
if testzero(i)=0 then testzero(i)=.;
end;
run;
proc print;
run;

output:

Example 1
Obs
1
2
3
4
5

var1
7
0
9
5
8

var2
1
0
9
6
3

var3
4
8
0
2
0

dept
101
410
600
700
901

qrt1
3
8
.
6
3

qrt2
.
7
.
5
8

Example 2
Obs
1
2
3
4
5

qrt3
4
5
6
6
7

qrt4
9
8
7
9
.

Example3:

/* Create three new variables by using an ARRAY statement, then use


*/
/* the SCAN function to pull the names out of the string and store them
*/
/* in the new variables.
*/
/* Create a sample data set */
data one;
input name $30.;
datalines;
daniel john green
mary jane smith
kathy diane jones
;
data two (drop=name i);
set one;
/* The LENGTH statement is used to give each variable a specific
length. */
/* To give all the variables the same length, specify a length after
the */
/* $ on the ARRAY statement.
*/

length first $10 middle $10 last $12;


array names(3) $ first middle last;
do i= 1 to 3;
names(i)=scan(name,i,' ');
end;
run;
proc print;
run;

output3:
Obs

first

middle

last

1
2
3

daniel
mary
kathy

john
jane
diane

green
smith
jones

Example4:

data weight;
array weigh(*) weigh1-weigh3;
array dateof(*) $ date1-date3;
input gender $ dateof(*) weigh(*);
datalines;
M 08/24/00 09/01/00 09/08/00 185 183 179
F 08/24/00 09/01/00 09/08/00 130 125 120
;
/*
/*
/*
/*

Use an array to group the 3 existing weight variables to


calculate the difference in weight from each weigh in. Use
an array to create 3 new variables to hold the calculated
weight loss.

*/
*/
*/
*/

data weight(drop=i);
set weight;
array weigh(*) weigh1-weigh3;
array diff(*) loss1-loss3 (0);
do i= 2 to dim(diff);
diff(i)=weigh(i) - weigh(i-1);
end;
run;
/* Group the weight, date, and loss variables into arrays so the data
set */
/* can be restructured. New variables are created to hold values of the
*/
/* arrays and a new observation is created for each date.
*/
data weight(keep=gender dateofweigh weight lost);
set weight;
array weigh(*) weigh1-weigh3;
array dateof(*) $ date1-date3;
array loss(*) loss1-loss3;
do i= 1 to dim(weigh);
weight=weigh(i);

dateofweigh=dateof(i);
lost=loss(i);
output;
end;
run;
proc print;
run;

output4:
Obs

gender

weight

dateofweigh

lost

1
2
3
4
5
6

M
M
M
F
F
F

185
183
179
130
125
120

08/24/00
09/01/00
09/08/00
08/24/00
09/01/00
09/08/00

0
-2
-4
0
-5
-5

Example5:
/* Create sample data */
data test;
input var1 var2 var3;
datalines;
10 20 30
100 . 300
. 40 400
;
/* The _TEMPORARY_ array values are used to populate the missing values
*/
/* in the TEST data set. The data set variables are put into an array
and
*/
/* there is a one to one correlation between the existing values and
the values */
/* in the _TEMPORARY_ array. A DO loop is used to evaluate if the value
is
*/
/* missing and if so, assign the new value.
*/
data new(drop=i);
set test;
array newval(3)_TEMPORARY_ (.1 .2 .3) ;
array now(3) var1 var2 var3;
do i=1 to 3;
if now(i)=. then now(i)=newval(i);
end;
run;
proc print;
run;

output5:

OBS
1
2
3

VAR1
10.0
100.0
0.1

VAR2
20.0
0.2
40.0

VAR3
30
300
400

Proc tabulate:
options ls=132;
data timerec;
input employee $ week $ phase $ hours;
cards;
Chen
11SEP89 Analysis 8
Chen
11SEP89 Analysis 7
Chen
11SEP89 Coding 2.5
Chen
11SEP89 Testing 8
Chen
11SEP89 Coding 8.5
Chen
11SEP89 Testing 6
Chen
11SEP89 Coding 4
Stewart 11SEP89 Coding 8
Stewart 11SEP89 Testing 4.5
Stewart 11SEP89 Coding 4.5
Stewart 11SEP89 Coding 10.5
Stewart 11SEP89 Testing 10
;
run;
proc tabulate data=timerec format=8.1;
class employee week phase;
var hours;
table week, employee all, sum*hours=' '*(phase all);
table week, employee all, pctsum*hours=' '*(phase all);
keylabel sum='Total Hours'
pctsum='Percentage of Hours';
title 'Summary of Project Hours';
run;

output:

Summary of Project Hours


WEEK 11SEP89
--------------------------------------------------------------------|
|
Total Hours
|
|
|-----------------------------------|
|
|
PHASE
|
|
|
|--------------------------|
|
|
|Analysis| Coding |Testing | ALL
|
|-------------------------------+--------+--------+--------+--------|
|EMPLOYEE
|
|
|
|
|
|-------------------------------|
|
|
|
|
|Chen
|
15.0|
15.0|
14.0|
44.0|
|-------------------------------+--------+--------+--------+--------|
|Stewart
|
.|
23.0|
14.5|
37.5|
|-------------------------------+--------+--------+--------+--------|
|ALL
|
15.0|
38.0|
28.5|
81.5|
---------------------------------------------------------------------

Summary of Project Hours


WEEK 11SEP89
--------------------------------------------------------------------|
|
Percentage of Hours
|
|
|-----------------------------------|
|
|
PHASE
|
|
|
|--------------------------|
|
|
|Analysis| Coding |Testing | ALL
|
|-------------------------------+--------+--------+--------+--------|
|EMPLOYEE
|
|
|
|
|
|-------------------------------|
|
|
|
|
|Chen
|
18.4|
18.4|
17.2|
54.0|
|-------------------------------+--------+--------+--------+--------|
|Stewart
|
.|
28.2|
17.8|
46.0|
|-------------------------------+--------+--------+--------+--------|
|ALL
|
18.4|
46.6|
35.0|
100.0|
---------------------------------------------------------------------

Example2:
data energy;
length State $2;
input Region Division state $ Type Expenditures;
datalines;
1 1 ME 1 708
1 1 ME 2 379
1 1 NH 1 597
1 1 NH 2 301
1 1 VT 1 353
1 1 VT 2 188
1 1 MA 1 3264
1 1 MA 2 2498
1 1 RI 1 531
1 1 RI 2 358
1 1 CT 1 2024
1 1 CT 2 1405
1 2 NY 1 8786
1 2 NY 2 7825
1 2 NJ 1 4115
1 2 NJ 2 3558
1 2 PA 1 6478
1 2 PA 2 3695
4 3 MT 1 322
4 3 MT 2 232
4 3 ID 1 392
4 3 ID 2 298
4 3 WY 1 194
4 3 WY 2 184
4 3 CO 1 1215
4 3 CO 2 1173
4 3 NM 1 545
4 3 NM 2 578
4 3 AZ 1 1694
4 3 AZ 2 1448
4 3 UT 1 621
4 3 UT 2 438

4
4
4
4
4
4
4
4
4
4
4
4
;

3
3
4
4
4
4
4
4
4
4
4
4

NV
NV
WA
WA
OR
OR
CA
CA
AK
AK
HI
HI

1
2
1
2
1
2
1
2
1
2
1
2

493
378
1680
1122
1014
756
10643
10114
349
329
273
298

proc format;
value regfmt 1='Northeast'
2='South'
3='Midwest'
4='West';
value divfmt 1='New England'
2='Middle Atlantic'
3='Mountain'
4='Pacific';
value usetype 1='Residential Customers'
2='Business Customers';
run;
options nodate pageno=1 linesize=80 pagesize=60;
/* Point ODS in the right direction. */
ods listing close;
ods html body="odstab3.htm";
proc tabulate data=energy format=dollar12. out=testout;
by region;
class division type;
var expenditures;
table division,
type*expenditures
/ rts=25;
format region regfmt. division divfmt. type usetype.;
title2 'Energy Expenditures for Each Region';
title3 '(millions of dollars)';
run;
/* Lets see how the data set generated from PROC TABULATE */
/* looks like.
*/
proc print data=testout;
title2 'PROC TABULATE output data set';

title3;
run;
/* All done, let us take a look. */
ods html close;

output:
Energy Expenditures for Each Region
(millions of dollars)
Region=Northeast
Type

Division

Residential Customers

Business Customers

Expenditures

Expenditures

Sum

Sum

$7,477

$5,129

New England
Middle Atlantic $19,379

$15,078

Energy Expenditures for Each Region


(millions of dollars)
Region=West
Type

Division

Residential Customers

Business Customers

Expenditures

Expenditures

Sum

Sum

$5,476

$4,729

$13,959

$12,619

Mountain
Pacific

PROC TABULATE output data set


OB
S

Region

Divisio
n

Northe
ast

New
Englan
d

Northe
ast

New
Englan
d

Type

_TYP
E_

_PAG
E_

_TABL
E_

Resident 11
ial
Custome
rs

7477

Busines 11
s
Custome
rs

5129

Northe
ast

Middle Resident 11
Atlantic ial
Custome
rs

19379

Northe
ast

Middle Busines 11
Atlantic s
Custome
rs

15078

West

Mounta Resident 11
in
ial
Custome
rs

5476

West

Mounta Busines 11
in
s
Custome
rs

4729

West

Pacific

Resident 11
ial
Custome
rs

13959

West

Pacific

Busines
s

12619

11

Expenditures_
Sum

OB
S

Region

Divisio
n

Type

_TYP
E_

_PAG
E_

_TABL
E_

Expenditures_
Sum

Custome
rs

Example3:
/* For simplicity, the infile statement has been removed */
/* and the raw data is being read via the cards statement */
options ls=132;
data year;
input mth $ qtr $ salesrep $14. type $ units price;
amtsold=units*price;
cards;
01 1 Hollingsworth Deluxe
260 29.50
01 1 Smith
Standard
41 19.95
01 1 Hollingsworth Standard 330 19.95
01 1 Jones
Standard 110 19.95
01 1 Smith
Deluxe
715 29.50
01 1 Jones
Standard 675 19.95
02 1 Smith
Standard 2045 19.95
02 1 Smith
Deluxe
10 29.50
02 1 Smith
Standard
40 19.95
02 1 Hollingsworth Standard 1030 19.95
02 1 Jones
Standard 153 19.95
02 1 Smith
Standard
98 19.95
03 1 Hollingsworth Standard 125 19.95
03 1 Jones
Standard 154 19.95
03 1 Smith
Standard 118 19.95
03 1 Hollingsworth Standard
25 19.95
03 1 Jones
Standard 525 19.95
03 1 Smith
Standard 310 19.95
04 2 Smith
Standard 150 19.95
04 2 Hollingsworth Standard 260 19.95
04 2 Hollingsworth Standard 530 19.95
04 2 Jones
Standard 1110 19.95
04 2 Smith
Standard 1715 19.95
04 2 Jones
Standard 675 19.95
05 2 Jones
Standard
45 19.95
05 2 Hollingsworth Standard 1120 19.95
05 2 Smith
Standard
40 19.95
05 2 Hollingsworth Standard 1030 19.95
05 2 Jones
Standard 153 19.95
05 2 Smith
Standard
98 19.95
06 2 Jones
Standard 154 19.95
06 2 Hollingsworth Deluxe
25 29.50
06 2 Jones
Standard 276 19.95
06 2 Hollingsworth Standard 125 19.95
06 2 Smith
Standard 512 19.95
06 2 Smith
Standard 1000 19.95
07 3 Smith
Standard 250 19.95
07 3 Hollingsworth Deluxe
60 29.50

07
07
07
07
07
07
07
07
07
07
07
07
07
07
07
07
07
08
08
08
08
08
08
08
08
08
08
08
08
08
08
08
08
08
08
08
08
09
09
09
09
09
09
09
09
09
09
09
09
09
09
09
09
09
09
10
10

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
4

Smith
Hollingsworth
Jones
Smith
Hollingsworth
Jones
Smith
Jones
Smith
Hollingsworth
Smith
Jones
Smith
Hollingsworth
Jones
Smith
Jones
Jones
Smith
Hollingsworth
Hollingsworth
Jones
Smith
Hollingsworth
Jones
Smith
Hollingsworth
Smith
Jones
Jones
Smith
Hollingsworth
Smith
Hollingsworth
Jones
Smith
Jones
Hollingsworth
Jones
Smith
Hollingsworth
Jones
Smith
Jones
Smith
Jones
Hollingsworth
Jones
Smith
Hollingsworth
Jones
Smith
Jones
Smith
Jones
Smith
Hollingsworth

Standard
Deluxe
Standard
Standard
Standard
Standard
Standard
Standard
Standard
Deluxe
Standard
Standard
Standard
Standard
Standard
Standard
Standard
Standard
Deluxe
Standard
Standard
Standard
Standard
Standard
Standard
Standard
Standard
Standard
Deluxe
Standard
Deluxe
Standard
Standard
Deluxe
Standard
Standard
Deluxe
Standard
Standard
Standard
Standard
Standard
Standard
Deluxe
Standard
Standard
Standard
Standard
Standard
Standard
Standard
Standard
Deluxe
Standard
Standard
Standard
Standard

90
30
110
90
130
110
265
275
1250
60
90
110
90
330
110
465
675
145
110
120
230
453
240
230
453
198
290
1198
45
145
110
330
240
50
453
198
225
125
254
118
1000
284
412
275
100
876
125
254
1118
175
284
412
275
100
876
250
530

19.95
29.50
19.95
19.95
19.95
19.95
19.95
19.95
19.95
29.50
19.95
19.95
19.95
19.95
19.95
19.95
19.95
19.95
29.50
19.95
19.95
19.95
19.95
29.50
19.95
19.95
19.95
19.95
29.50
19.95
29.50
19.95
19.95
29.50
19.95
19.95
29.50
19.95
19.95
19.95
19.95
19.95
19.95
29.50
19.95
19.95
19.95
19.95
19.95
19.95
19.95
19.95
29.50
19.95
19.95
19.95
19.95

10 4
10 4
10 4
10 4
11 4
11 4
11 4
11 4
11 4
11 4
12 4
12 4
12 4
12 4
12 4
run;

Jones
Hollingsworth
Jones
Smith
Hollingsworth
Jones
Smith
Jones
Smith
Hollingsworth
Smith
Jones
Hollingsworth
Jones
Hollingsworth

Standard 975 19.95


Standard 265 19.95
Standard
55 19.95
Standard 365 19.95
Standard 1230 19.95
Standard 453 19.95
Standard 198 19.95
Standard
70 19.95
Standard 120 19.95
Deluxe
150 29.50
Standard 1000 19.95
Standard 876 19.95
Deluxe
125 29.50
Standard 1254 19.95
Standard 175 19.95

proc tabulate data=year format=comma10.;


title 'Counting Frequencies of Occurrence';
class salesrep;
table salesrep;
run;
proc tabulate data=year format=comma10.;
title 'Obtaining Totals for Single Variables in Two Dimensions';
class salesrep;
var amtsold;
table salesrep,
amtsold;
run;
proc tabulate data=year format=comma10.;
title 'Obtaining Totals for Single Variables in Three Dimensions';
class salesrep qtr;
var amtsold;
table salesrep,
qtr,
amtsold;
run;
proc tabulate data=year format=comma10.;
title 'Obtaining Totals for Subgroups by Crossing Variables';
class salesrep type;
var amtsold;
table salesrep*type,
amtsold*f=dollar16.2;
run;
proc tabulate data=year format=comma10.;
title 'Obtaining Two Sets of Totals by Concatenating Variables';
class salesrep type;
var amtsold;
table salesrep*type,
amtsold*f=dollar16.2 amtsold*n;
run;
proc tabulate data=year format=comma10.;

title 'Obtaining Averages';


class salesrep type;
var amtsold;
table salesrep*type,
amtsold*f=dollar16.2 amtsold*mean*f=dollar16.2 amtsold*n;
run;
proc tabulate data=year format=comma10.;
title 'Obtaining Totals for All Class Variables';
class salesrep type;
var amtsold;
table salesrep*type all,
amtsold*f=dollar16.2 amtsold*mean*f=dollar16.2 amtsold*n;
run;

output:

Counting Frequencies of Occurrence


---------------------------------|
SALESREP
|
|--------------------------------|
|Hollingsw-|
|
|
|
orth
| Jones
| Smith
|
|----------+----------+----------|
|
N
|
N
|
N
|
|----------+----------+----------|
|
32|
38|
40|
----------------------------------

Obtaining Totals for Single Variables in Two Dimensions


-------------------------------------------|
| AMTSOLD |
|
|----------|
|
|
SUM
|
|-------------------------------+----------|
|SALESREP
|
|
|-------------------------------|
|
|Hollingsworth
|
221,324|
|-------------------------------+----------|
|Jones
|
295,111|
|-------------------------------+----------|
|Smith
|
327,606|
--------------------------------------------

Obtaining Totals for Single Variables in Three Dimensions


SALESREP Hollingsworth
-------------------------------------------|
| AMTSOLD |
|
|----------|
|
|
SUM
|

|-------------------------------+----------|
|QTR
|
|
|-------------------------------|
|
|1
|
37,795|
|-------------------------------+----------|
|2
|
61,884|
|-------------------------------+----------|
|3
|
69,642|
|-------------------------------+----------|
|4
|
52,003|
--------------------------------------------

Obtaining Totals for Single Variables in Three Dimensions


SALESREP Jones
-------------------------------------------|
| AMTSOLD |
|
|----------|
|
|
SUM
|
|-------------------------------+----------|
|QTR
|
|
|-------------------------------|
|
|1
|
32,259|
|-------------------------------+----------|
|2
|
48,139|
|-------------------------------+----------|
|3
|
141,237|
|-------------------------------+----------|
|4
|
73,476|
--------------------------------------------

Obtaining Totals for Single Variables in Three Dimensions


SALESREP Smith
-------------------------------------------|
| AMTSOLD |
|
|----------|
|
|
SUM
|
|-------------------------------+----------|
|QTR
|
|
|-------------------------------|
|
|1
|
74,295|
|-------------------------------+----------|
|2
|
70,124|
|-------------------------------+----------|
|3
|
144,624|
|-------------------------------+----------|
|4
|
38,563|
--------------------------------------------

Obtaining Totals for Subgroups by Crossing Variables

-------------------------------------------------|
|
AMTSOLD
|
|
|----------------|
|
|
SUM
|
|-------------------------------+----------------|
|SALESREP
|TYPE
|
|
|---------------+---------------|
|
|Hollingsworth |Deluxe
|
$22,420.00|
|
|---------------+----------------|
|
|Standard
|
$198,903.50|
|---------------+---------------+----------------|
|Jones
|Deluxe
|
$24,190.00|
|
|---------------+----------------|
|
|Standard
|
$270,921.00|
|---------------+---------------+----------------|
|Smith
|Deluxe
|
$27,877.50|
|
|---------------+----------------|
|
|Standard
|
$299,728.80|
--------------------------------------------------

Obtaining Two Sets of Totals by Concatenating Variables


------------------------------------------------------------|
|
AMTSOLD
| AMTSOLD |
|
|----------------+----------|
|
|
SUM
|
N
|
|-------------------------------+----------------+----------|
|SALESREP
|TYPE
|
|
|
|---------------+---------------|
|
|
|Hollingsworth |Deluxe
|
$22,420.00|
8|
|
|---------------+----------------+----------|
|
|Standard
|
$198,903.50|
24|
|---------------+---------------+----------------+----------|
|Jones
|Deluxe
|
$24,190.00|
4|
|
|---------------+----------------+----------|
|
|Standard
|
$270,921.00|
34|
|---------------+---------------+----------------+----------|
|Smith
|Deluxe
|
$27,877.50|
4|
|
|---------------+----------------+----------|
|
|Standard
|
$299,728.80|
36|
-------------------------------------------------------------

Obtaining Averages
----------------------------------------------------------------------------|
|
AMTSOLD
|
AMTSOLD
|
AMTSOLD |
|
|----------------+---------------+----------|
|
|
SUM
|
MEAN
|
N
|

|-------------------------------+----------------+---------------+----------|
|SALESREP
|TYPE
|
|
|
|
|---------------+---------------|
|
|
|
|Hollingsworth |Deluxe
|
$22,420.00|
$2,802.50|
8|
|
|---------------+----------------+---------------+----------|
|
|Standard
|
$198,903.50|
$8,287.65|
24|
|---------------+---------------+----------------+---------------+----------|
|Jones
|Deluxe
|
$24,190.00|
$6,047.50|
4|
|
|---------------+----------------+---------------+----------|
|
|Standard
|
$270,921.00|
$7,968.26|
34|
|---------------+---------------+----------------+---------------+----------|
|Smith
|Deluxe
|
$27,877.50|
$6,969.38|
4|
|
|---------------+----------------+---------------+----------|
|
|Standard
|
$299,728.80|
$8,325.80|
36|
-----------------------------------------------------------------------------

Obtaining Totals for All Class Variables


----------------------------------------------------------------------------|
|
AMTSOLD
|
AMTSOLD
|
AMTSOLD |
|
|----------------+---------------+----------|
|
|
SUM
|
MEAN
|
N
|
|-------------------------------+----------------+---------------+----------|
|SALESREP
|TYPE
|
|
|
|
|---------------+---------------|
|
|
|
|Hollingsworth |Deluxe
|
$22,420.00|
$2,802.50|
8|
|
|---------------+----------------+---------------+----------|
|
|Standard
|
$198,903.50|
$8,287.65|
24|
|---------------+---------------+----------------+---------------+----------|

|Jones
|Deluxe
|
$24,190.00|
$6,047.50|
4|
|
|---------------+----------------+---------------+----------|
|
|Standard
|
$270,921.00|
$7,968.26|
34|
|---------------+---------------+----------------+---------------+----------|
|Smith
|Deluxe
|
$27,877.50|
$6,969.38|
4|
|
|---------------+----------------+---------------+----------|
|
|Standard
|
$299,728.80|
$8,325.80|
36|
|-------------------------------+----------------+---------------+----------|
|ALL
|
$844,040.80|
$7,673.10|
110|
----------------------------------------------------------------------------options ps=60 ls=80;
/* Point ODS in the right direction. */
ods listing close;
ods html file="odstab2.htm" style=brick;
proc format;
value mthfmt
1='Jan'
2='Feb'
3='Mar'
4='Apr'
5='May'
6='Jun'
7='Jul'
8='Aug'
9='Sep'
10='Oct'
11='Nov'
12='Dec';
run;
data records;
retain seed1 543;
drop ind;
do month = 1 to 7;
do day = 1 to 30;
call ranuni( seed1, ind );
dailyTotals = 1000 + (1000 * ind);
output;
end;
end;
drop seed1;
format month mthfmt. dailyTotals dollar10.2;
run;

/* Table generated without PreLoadFmt. */


title2 "Table w/o PreLoadFmt";
proc tabulate;
class month;
var dailyTotals;
table month, dailyTotals*(sum min max mean median) /
printMiss box='1997 Year to Date';
run;
/* Table generated with PreLoadFmt. */
title2 "Table with PreLoadFmt";
proc tabulate;
class month / PreLoadFmt;
var dailyTotals;
table month, dailyTotals*(sum min max mean median) /
printMiss box='1997 Year to Date';
run;
/* All done, let us take a look. */
ods html close;

OUTPUT:
Table w/o PreLoadFmt
1997 Year to Date

dailyTotals
Sum

Min

Max

Mean

Median

45389.76

1028.20

1993.58

1512.99

1471.46

Feb

45379.07

1009.95

1991.36

1512.64

1511.33

Mar

41152.30

1015.88

1953.27

1371.74

1339.26

Apr

44917.96

1008.78

1995.04

1497.27

1566.73

May

46752.22

1003.65

1970.68

1558.41

1607.02

Jun

46306.09

1033.46

1955.49

1543.54

1602.82

Jul

44898.67

1042.00

1970.67

1496.62

1519.81

month
Jan

Table with PreLoadFmt


1997 Year to Date

dailyTotals
Sum

Min

Max

Mean

Median

45389.76

1028.20

1993.58

1512.99

1471.46

Feb

45379.07

1009.95

1991.36

1512.64

1511.33

Mar

41152.30

1015.88

1953.27

1371.74

1339.26

Apr

44917.96

1008.78

1995.04

1497.27

1566.73

May

46752.22

1003.65

1970.68

1558.41

1607.02

Jun

46306.09

1033.46

1955.49

1543.54

1602.82

Jul

44898.67

1042.00

1970.67

1496.62

1519.81

Aug

Sep

Oct

Nov

Dec

month
Jan

Proc summary:
DATA VIRUS;
INPUT DILUTION $ COMPOUND $ TIME @@;
IF DILUTION='A' THEN DL=1;
ELSE IF DILUTION='B' THEN DL=2;
ELSE IF DILUTION='C' THEN DL=4;
CARDS;
A PA 87 A PA 90
A PM 82 A PM 71
A UN 72 A UN 77
B PA 79 B PA 80
B PM 73 B PM 72

B
C
C
C
;

UN
PA
PM
UN

70
77
72
62

B
C
C
C

UN
PA
PM
UN

66
81
68
61

/* Use class variable COMPOUND to group data. */


PROC SUMMARY PRINT;
CLASS COMPOUND;
RUN;
PROC SUMMARY PRINT N MEAN STD STDERR SUM VAR MIN MAX CV CSS USS
RANGE NMISS;
VAR TIME DL;
CLASS COMPOUND;
RUN;
PROC SORT;
BY COMPOUND;
RUN;
/* Use by variable to group data, slightly */
/* different from class.
*/
PROC SUMMARY PRINT;
BY COMPOUND;
VAR TIME DL;
RUN;
PROC SUMMARY DATA=VIRUS;
VAR TIME;
CLASS COMPOUND;
OUTPUT OUT=OUTA MEAN=M STD=S N=COUNT;
RUN;
PROC PRINT;
RUN;
PROC SUMMARY DATA=VIRUS;
VAR TIME;
BY COMPOUND;
OUTPUT OUT=OUTA MEAN=M STD=S N=COUNT;
RUN;
PROC PRINT;
RUN;

Output:

The SUMMARY Procedure


N
COMPOUND
Obs
--------------PA
6
PM

UN
6
---------------

The SUMMARY Procedure


N
COMPOUND Obs Variable
N
Mean
Std Dev
Std Error
-----------------------------------------------------------------------PA
6 TIME
6
82.3333333
5.0464509
2.0602050
DL
6
2.3333333
1.3662601
0.5577734
PM

UN

TIME
DL

6
6

73.0000000
2.3333333

4.7328638
1.3662601

1.9321836
0.5577734

TIME
6
68.0000000
6.1644140
2.5166115
DL
6
2.3333333
1.3662601
0.5577734
-----------------------------------------------------------------------N
COMPOUND Obs Variable
Sum
Variance
Minimum
Maximum
-----------------------------------------------------------------------------PA
6 TIME
494.0000000
25.4666667
77.0000000
90.0000000
DL
14.0000000
1.8666667
1.0000000
4.0000000
PM
82.0000000

TIME
DL

438.0000000

22.4000000

68.0000000

14.0000000

1.8666667

1.0000000

408.0000000

38.0000000

61.0000000

4.0000000
UN
77.0000000

TIME

DL
14.0000000
1.8666667
1.0000000
4.0000000
-----------------------------------------------------------------------------N
Coeff of
COMPOUND Obs Variable
Variation Corrected SS
USS
Range
-----------------------------------------------------------------------------PA
6 TIME
6.1292926
127.3333333
40800.00
13.0000000
DL
58.5540044
9.3333333
42.0000000
3.0000000
PM
14.0000000
3.0000000

TIME
DL

6.4833751

112.0000000

32086.00

58.5540044

9.3333333

42.0000000

UN
16.0000000

TIME

9.0653147

190.0000000

27934.00

DL
58.5540044
9.3333333
42.0000000
3.0000000
-----------------------------------------------------------------------------N
N
COMPOUND Obs Variable Miss
----------------------------PA
6 TIME
0
DL
0
PM

UN

TIME
DL

0
0

TIME
0
DL
0
-----------------------------

COMPOUND=PA
The SUMMARY Procedure
Variable
N
Mean
Std Dev
Minimum
Maximum
----------------------------------------------------------------------------TIME
6
82.3333333
5.0464509
77.0000000
90.0000000
DL
6
2.3333333
1.3662601
1.0000000
4.0000000
----------------------------------------------------------------------------COMPOUND=PM
Variable
N
Mean
Std Dev
Minimum
Maximum
----------------------------------------------------------------------------TIME
6
73.0000000
4.7328638
68.0000000
82.0000000
DL
6
2.3333333
1.3662601
1.0000000
4.0000000
----------------------------------------------------------------------------COMPOUND=UN
Variable
Maximum

Mean

Std Dev

Minimum

----------------------------------------------------------------------------TIME
6
68.0000000
6.1644140
61.0000000
77.0000000
DL
6
2.3333333
1.3662601
1.0000000
4.0000000
-----------------------------------------------------------------------------

Obs

COMPOUND

_TYPE_

_FREQ_

COUNT

1
2
3
4

PA
PM
UN

0
1
1
1

18
6
6
6

74.4444
82.3333
73.0000
68.0000

7.91292
5.04645
4.73286
6.16441

18
6
6
6

Obs

COMPOUND

_TYPE_

_FREQ_

COUNT

1
2
3

PA
PM
UN

0
0
0

6
6
6

82.3333
73.0000
68.0000

5.04645
4.73286
6.16441

6
6
6

S-ar putea să vă placă și