30
/* 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

SAS arrays

Embed Size (px)

DESCRIPTION

Describes how SAS arrays functions

Citation preview

Page 1: SAS arrays

/* 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;

Page 2: SAS arrays

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

proc print;run;

output:Example 1

Obs var1 var2 var3 1 7 1 4 2 0 0 8 3 9 9 0 4 5 6 2 5 8 3 0

Example 2

Obs dept qrt1 qrt2 qrt3 qrt4 1 101 3 . 4 9 2 410 8 7 5 8 3 600 . . 6 7 4 700 6 5 6 9 5 901 3 8 7 .

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 greenmary jane smithkathy 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. */

Page 3: SAS arrays

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 daniel john green 2 mary jane smith 3 kathy diane 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 179F 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);

Page 4: SAS arrays

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

proc print;run;

output4:Obs gender weight dateofweigh lost

1 M 185 08/24/00 0 2 M 183 09/01/00 -2 3 M 179 09/08/00 -4 4 F 130 08/24/00 0 5 F 125 09/01/00 -5 6 F 120 09/08/00 -5

Example5:/* Create sample data */

data test; input var1 var2 var3;datalines; 10 20 30100 . 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 VAR1 VAR2 VAR3

Page 5: SAS arrays

1 10.0 20.0 302 100.0 0.2 3003 0.1 40.0 400

Proc tabulate:

options ls=132;data timerec; input employee $ week $ phase $ hours; cards;Chen 11SEP89 Analysis 8Chen 11SEP89 Analysis 7Chen 11SEP89 Coding 2.5Chen 11SEP89 Testing 8Chen 11SEP89 Coding 8.5Chen 11SEP89 Testing 6Chen 11SEP89 Coding 4Stewart 11SEP89 Coding 8Stewart 11SEP89 Testing 4.5Stewart 11SEP89 Coding 4.5Stewart 11SEP89 Coding 10.5Stewart 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

Page 6: SAS arrays

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 7081 1 ME 2 3791 1 NH 1 5971 1 NH 2 3011 1 VT 1 3531 1 VT 2 1881 1 MA 1 32641 1 MA 2 24981 1 RI 1 5311 1 RI 2 3581 1 CT 1 20241 1 CT 2 14051 2 NY 1 87861 2 NY 2 78251 2 NJ 1 41151 2 NJ 2 35581 2 PA 1 64781 2 PA 2 36954 3 MT 1 3224 3 MT 2 2324 3 ID 1 3924 3 ID 2 2984 3 WY 1 1944 3 WY 2 1844 3 CO 1 12154 3 CO 2 11734 3 NM 1 5454 3 NM 2 5784 3 AZ 1 16944 3 AZ 2 14484 3 UT 1 6214 3 UT 2 4384 3 NV 1 493

Page 7: SAS arrays

4 3 NV 2 3784 4 WA 1 16804 4 WA 2 11224 4 OR 1 10144 4 OR 2 7564 4 CA 1 106434 4 CA 2 101144 4 AK 1 3494 4 AK 2 3294 4 HI 1 2734 4 HI 2 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;

Page 8: SAS arrays

run;

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

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

Region=Northeast

  Type

Residential Customers Business Customers

Expenditures Expenditures

Sum Sum

Division $7,477 $5,129

New England

Middle Atlantic $19,379 $15,078

Page 9: SAS arrays

Energy Expenditures for Each Region(millions of dollars)

Region=West

  Type

Residential Customers Business Customers

Expenditures Expenditures

Sum Sum

Division $5,476 $4,729

Mountain

Pacific $13,959 $12,619

Page 10: SAS arrays

PROC TABULATE output data set

OBS

Region Division

Type _TYPE_

_PAGE_

_TABLE_

Expenditures_Sum

1 Northeast

New England

Residential Customers

11 1 1 7477

2 Northeast

New England

Business Customers

11 1 1 5129

3 Northeast

Middle Atlantic

Residential Customers

11 1 1 19379

4 Northeast

Middle Atlantic

Business Customers

11 1 1 15078

5 West Mountain

Residential Customers

11 1 1 5476

6 West Mountain

Business Customers

11 1 1 4729

7 West Pacific Residential Customers

11 1 1 13959

8 West Pacific Busines 11 1 1 12619

Page 11: SAS arrays

OBS

Region Division

Type _TYPE_

_PAGE_

_TABLE_

Expenditures_Sum

s Customers

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.5001 1 Smith Standard 41 19.9501 1 Hollingsworth Standard 330 19.9501 1 Jones Standard 110 19.9501 1 Smith Deluxe 715 29.5001 1 Jones Standard 675 19.9502 1 Smith Standard 2045 19.9502 1 Smith Deluxe 10 29.5002 1 Smith Standard 40 19.9502 1 Hollingsworth Standard 1030 19.9502 1 Jones Standard 153 19.9502 1 Smith Standard 98 19.9503 1 Hollingsworth Standard 125 19.9503 1 Jones Standard 154 19.9503 1 Smith Standard 118 19.9503 1 Hollingsworth Standard 25 19.9503 1 Jones Standard 525 19.9503 1 Smith Standard 310 19.9504 2 Smith Standard 150 19.9504 2 Hollingsworth Standard 260 19.9504 2 Hollingsworth Standard 530 19.9504 2 Jones Standard 1110 19.9504 2 Smith Standard 1715 19.9504 2 Jones Standard 675 19.9505 2 Jones Standard 45 19.9505 2 Hollingsworth Standard 1120 19.9505 2 Smith Standard 40 19.9505 2 Hollingsworth Standard 1030 19.9505 2 Jones Standard 153 19.9505 2 Smith Standard 98 19.9506 2 Jones Standard 154 19.9506 2 Hollingsworth Deluxe 25 29.5006 2 Jones Standard 276 19.9506 2 Hollingsworth Standard 125 19.9506 2 Smith Standard 512 19.9506 2 Smith Standard 1000 19.95

Page 12: SAS arrays

07 3 Smith Standard 250 19.9507 3 Hollingsworth Deluxe 60 29.5007 3 Smith Standard 90 19.9507 3 Hollingsworth Deluxe 30 29.5007 3 Jones Standard 110 19.9507 3 Smith Standard 90 19.9507 3 Hollingsworth Standard 130 19.9507 3 Jones Standard 110 19.9507 3 Smith Standard 265 19.9507 3 Jones Standard 275 19.9507 3 Smith Standard 1250 19.9507 3 Hollingsworth Deluxe 60 29.5007 3 Smith Standard 90 19.9507 3 Jones Standard 110 19.9507 3 Smith Standard 90 19.9507 3 Hollingsworth Standard 330 19.9507 3 Jones Standard 110 19.9507 3 Smith Standard 465 19.9507 3 Jones Standard 675 19.9508 3 Jones Standard 145 19.9508 3 Smith Deluxe 110 29.5008 3 Hollingsworth Standard 120 19.9508 3 Hollingsworth Standard 230 19.9508 3 Jones Standard 453 19.9508 3 Smith Standard 240 19.9508 3 Hollingsworth Standard 230 29.5008 3 Jones Standard 453 19.9508 3 Smith Standard 198 19.9508 3 Hollingsworth Standard 290 19.9508 3 Smith Standard 1198 19.9508 3 Jones Deluxe 45 29.5008 3 Jones Standard 145 19.9508 3 Smith Deluxe 110 29.5008 3 Hollingsworth Standard 330 19.9508 3 Smith Standard 240 19.9508 3 Hollingsworth Deluxe 50 29.5008 3 Jones Standard 453 19.9508 3 Smith Standard 198 19.9508 3 Jones Deluxe 225 29.5009 3 Hollingsworth Standard 125 19.9509 3 Jones Standard 254 19.9509 3 Smith Standard 118 19.9509 3 Hollingsworth Standard 1000 19.9509 3 Jones Standard 284 19.9509 3 Smith Standard 412 19.9509 3 Jones Deluxe 275 29.5009 3 Smith Standard 100 19.9509 3 Jones Standard 876 19.9509 3 Hollingsworth Standard 125 19.9509 3 Jones Standard 254 19.9509 3 Smith Standard 1118 19.9509 3 Hollingsworth Standard 175 19.9509 3 Jones Standard 284 19.9509 3 Smith Standard 412 19.9509 3 Jones Deluxe 275 29.5009 3 Smith Standard 100 19.9509 3 Jones Standard 876 19.95

Page 13: SAS arrays

10 4 Smith Standard 250 19.9510 4 Hollingsworth Standard 530 19.9510 4 Jones Standard 975 19.9510 4 Hollingsworth Standard 265 19.9510 4 Jones Standard 55 19.9510 4 Smith Standard 365 19.9511 4 Hollingsworth Standard 1230 19.9511 4 Jones Standard 453 19.9511 4 Smith Standard 198 19.9511 4 Jones Standard 70 19.9511 4 Smith Standard 120 19.9511 4 Hollingsworth Deluxe 150 29.5012 4 Smith Standard 1000 19.9512 4 Jones Standard 876 19.9512 4 Hollingsworth Deluxe 125 29.5012 4 Jones Standard 1254 19.9512 4 Hollingsworth Standard 175 19.95run;

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;

Page 14: SAS arrays

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 |

Page 15: SAS arrays

| |----------|| | 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|--------------------------------------------

Page 16: SAS arrays

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 || |----------------+----------------+----------|

Page 17: SAS arrays

| | 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|

Page 18: SAS arrays

|---------------+---------------+----------------+----------------+----------||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;

Page 19: SAS arrays

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

month 45389.76 1028.20 1993.58 1512.99 1471.46

Jan

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

Page 20: SAS arrays
Page 21: SAS arrays

Table with PreLoadFmt

1997 Year to Date dailyTotals

Sum Min Max Mean Median

month 45389.76 1028.20 1993.58 1512.99 1471.46

Jan

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 . . . . .

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 90A PM 82 A PM 71A UN 72 A UN 77

Page 22: SAS arrays

B PA 79 B PA 80B PM 73 B PM 72B UN 70 B UN 66C PA 77 C PA 81C PM 72 C PM 68C UN 62 C UN 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

NCOMPOUND Obs---------------PA 6

Page 23: SAS arrays

PM 6

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

The SUMMARY Procedure

NCOMPOUND 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 6 TIME 6 73.0000000 4.7328638 1.9321836 DL 6 2.3333333 1.3662601 0.5577734

UN 6 TIME 6 68.0000000 6.1644140 2.5166115 DL 6 2.3333333 1.3662601 0.5577734------------------------------------------------------------------------

NCOMPOUND 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 6 TIME 438.0000000 22.4000000 68.0000000 82.0000000 DL 14.0000000 1.8666667 1.0000000 4.0000000

UN 6 TIME 408.0000000 38.0000000 61.0000000 77.0000000 DL 14.0000000 1.8666667 1.0000000 4.0000000-------------------------------------------------------------------------------

N Coeff ofCOMPOUND 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 6 TIME 6.4833751 112.0000000 32086.00 14.0000000

Page 24: SAS arrays

DL 58.5540044 9.3333333 42.0000000 3.0000000

UN 6 TIME 9.0653147 190.0000000 27934.00 16.0000000 DL 58.5540044 9.3333333 42.0000000 3.0000000-------------------------------------------------------------------------------

N NCOMPOUND Obs Variable Miss-----------------------------PA 6 TIME 0 DL 0

PM 6 TIME 0 DL 0

UN 6 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.0000000DL 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.0000000DL 6 2.3333333 1.3662601 1.0000000 4.0000000------------------------------------------------------------------------------

COMPOUND=UN

Page 25: SAS arrays

Variable N Mean Std Dev Minimum Maximum------------------------------------------------------------------------------TIME 6 68.0000000 6.1644140 61.0000000 77.0000000DL 6 2.3333333 1.3662601 1.0000000 4.0000000------------------------------------------------------------------------------

Obs COMPOUND _TYPE_ _FREQ_ M S COUNT

1 0 18 74.4444 7.91292 18 2 PA 1 6 82.3333 5.04645 6 3 PM 1 6 73.0000 4.73286 6 4 UN 1 6 68.0000 6.16441 6

Obs COMPOUND _TYPE_ _FREQ_ M S COUNT

1 PA 0 6 82.3333 5.04645 6 2 PM 0 6 73.0000 4.73286 6 3 UN 0 6 68.0000 6.16441 6