Task
|
Statement
|
Example
|
---|---|---|
Reference an Excel workbook
file
|
SAS/ACCESS LIBNAME statement
|
LIBNAME results
'c:certdataexercise.xlsx'; |
Write out the contents
of the SAS Library
|
PROC CONTENTS
|
proc contents data=results._all_; |
Execute the PROC CONTENTS
statement
|
RUN statement
|
run; |
Name and create a new
SAS data set
|
DATA statement
|
data work.stress; |
Read in an Excel worksheet
(as the input data for the new SAS data set)
|
SET statement
|
set results.'ActLevel$'n; |
Execute the DATA step
|
RUN statement
|
run; |
View the contents of
a particular data set
|
PROC PRINT
|
proc print data=stress; |
Execute the PROC PRINT
statement
|
RUN statement
|
run; |
Syntax, SAS/ACCESS LIBNAME
statement:
LIBNAME <libref>XLSX <'physical-path-and-filename.xls'><options>;
libname results
XLSX
'c:certdataexercise.xlsx'; |
c:users
.
libname results XLSX 'c:certdataexercise.xlsx';
data work.stress; set results.'ActivityLevels'n; run;
data work.stress; set results.'ActivityLevels'n; where ActLevel='HIGH'; run;
proc print data=work.stress; run; proc print data=results.ActivityLevels'n; run;
data funnies (LABEL= 'Comics Character Data');
input Id Name $ Height Weight DoB MMDDYY8. @@;
Label Id = 'Identification no.';
Height = 'Height in inches';
Weight = 'Weight in pounds';
DoB = 'Date of Birth';
INFORMAT DoB MMDDYY8.;
FORMAT DoB WORDDATE18.;
Datalines;
53 Susie 42 41 07-11-93
54 Charlie 46 55 10-26-90
55 Calvin 40 35 01-10-91
56 Lucy 46 52 01-13-95
;
proc contents data=funnies;
run;
libname results XLSX "c:usersexercise.xlsx";
proc print data=results.'tests'n;
run;
libname results clear;