![]() Chapter Contents |
![]() Previous |
![]() Next |
| SAS/ACCESS Software for PC File Formats: Reference |
| Using the FREQ Procedure |
proc access dbms=dbf;
/* create access descriptor */
create adlib.invoice.access;
path="c:\sasdemo\invoice.dbf";
assign;
rename invoicenum = invnum
amtbilled = amtbilld ;
format paidon date9.
invoicenum 5.0
billedby 6.0;
assign=yes;
create vlib.inv.view;
/* create vlib.inv view */
select invoicenum amtbilled
country billedby paidon;
list all;
run;
proc freq data=vlib.inv;
/* example */
tables country;
title 'Data Described by VLIB.INV';
run;
Frequency Table for Variable COUNTRY Described by View Descriptor VLIB.INV shows the one-way frequency table that this example generates.
Frequency Table for Variable COUNTRY Described by View Descriptor VLIB.INV
Data Described by VLIB.INV 6
COUNTRY
Cumulative Cumulative
COUNTRY Frequency Percent Frequency Percent
--------------------------------------------------------------
Argentina 2 11.76 2 11.76
Australia 1 5.88 3 17.65
Brazil 4 23.53 7 41.18
USA 10 58.82 17 100.00 |
For more information on the FREQ procedure, see SAS Language and Procedures: Usage and SAS Procedures Guide.
| Using the MEANS Procedure |
proc access dbms=xls;
create adlib.order.access;
/* create access descriptor */
path="c:\sasdemo\orders.xls";
worksheet=shee1;
getnames=yes;
skiprows=2;
scantype=5;
mixed=yes;
assign=yes;
rename dateorderd = dateord
processdby = procesby;
format dateorderd date9.
shipped date9.
ordernum 5.0
length 4.0
stocknum 4.0
takenby 6.0
processdby 6.0
fabcharges 12.2;
list all;
create vlib.usaordr.view;
/* create vlib.usaordr view */
select ordernum stocknum length
fabcharges shipto;
subset where shipto like '1%';
run;
proc sort data=vlib.usaordr out=work.usaorder;
by shipto;
run;
proc means data=work.usaordr mean
/* example */
sum n nmiss maxdec=0;
by shipto;
var length fabcharg;
title 'Data Described by VLIB.USAORDR';
run;
Statistics on Fabric Length and Charges for Each U.S. Customer shows the output for this example.
Statistics on Fabric Length and Charges for Each U.S. Customer
Data Described by VLIB.USAORDR 7
-------------------------------- SHIPTO=14324742 -------------------------------
Variable Label Mean Sum N Nmiss
-----------------------------------------------------------
LENGTH LENGTH 1095 4380 4 0
FABCHARG FABCHARGES 1934460 3868920 2 2
-----------------------------------------------------------
-------------------------------- SHIPTO=14898029 -------------------------------
Variable Label Mean Sum N Nmiss
-----------------------------------------------------------
LENGTH LENGTH 2500 5000 2 0
FABCHARG FABCHARGES 1400825 2801650 2 0
-----------------------------------------------------------
-------------------------------- SHIPTO=15432147 -------------------------------
Variable Label Mean Sum N Nmiss
-----------------------------------------------------------
LENGTH LENGTH 725 2900 4 0
FABCHARG FABCHARGES 252149 504297 2 2
-----------------------------------------------------------
-------------------------------- SHIPTO=18543489 -------------------------------
Variable Label Mean Sum N Nmiss
-----------------------------------------------------------
LENGTH LENGTH 303 1820 6 0
FABCHARG FABCHARGES 11063836 44255344 4 2
-----------------------------------------------------------
-------------------------------- SHIPTO=19783482 -------------------------------
Variable Label Mean Sum N Nmiss
-----------------------------------------------------------
LENGTH LENGTH 450 1800 4 0
FABCHARG FABCHARGES 252149 1008594 4 0
-----------------------------------------------------------
-------------------------------- SHIPTO=19876078 -------------------------------
Variable Label Mean Sum N Nmiss
-----------------------------------------------------------
LENGTH LENGTH 690 1380 2 0
FABCHARG FABCHARGES . . 0 2
----------------------------------------------------------- |
For more information on the MEANS procedure, see SAS Procedures Guide.
| Using the RANK Procedure |
proc access dbms=dbf;
create adlib.employ.access;
/* create access descriptor */
path="c:\sasdemo\employees";
drop salary;
list all;
create vlib.emps.view;
/* create vlib.emps view */
select empid jobcode birthdate
lastname jobcode;
format birthdate date9.
empid 6.0;
subset where jobcode=602;
run;
proc rank data=vlib.emps out=dlib.rankexam;
/* example */
var birthdat;
ranks daterank;
run;
proc sort data=dlib.rankexam;
by lastname;
run;
proc print data=dlib.rankexam(drop=jobcode);
title 'Order of Dept 602 Employee Birthdays';
run;
Data stored in the DBF file must be extracted and placed in a SAS data set before they can be sorted with a SAS procedure. (This restriction also applies to data from other PC files.) The DROP= data set option is used in the PROC PRINT statement because the JOBCODE variable is not needed in the output. The JOBCODE variable is required in the SELECT statement so it can be used in the WHERE statement. The JOBCODE variable is then included in the view descriptor, even though it is not needed in the output. Ranking of Employee Birthdays shows the result of this example.
Order of Dept 602 Employee Birthdays
OBS EMPID BIRTHDAT LASTNAME DATERANK
1 456910 24SEP1953 ARDIS 5
2 237642 13MAR1954 BATTERSBY 6
3 239185 28AUG1959 DOS REMEDIOS 7
4 321783 03JUN1935 GONZALES 2
5 120591 12FEB1946 HAMMERSTEIN 4
6 135673 21MAR1961 HEMESLY 8
7 456921 12MAY1962 KRAUSE 9
8 457232 15OCT1963 LOVELL 11
9 423286 31OCT1964 MIFUNE 12
10 216382 24JUL1963 PURINTON 10
11 234967 21DEC1967 SMITH 13
12 212916 29MAY1928 WACHBERGER 1
13 119012 05JAN1946 WOLF-PROVENZA 3 |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.