Read and Write
SAS Data Sets
The Easy, Easy Way
in Windows
See www.stattutorials.com/SASDATA
for
files mentioned in this tutorial
© TexaSoft,
2007
These SAS statistics tutorials
briefly explain the use and interpretation of standard statistical analysis
techniques for Medical, Pharmaceutical, Clinical Trials, Marketing or Scientific
Research. The examples include how-to instructions for SAS Software.
Reading and creating permanent SAS
data sets in Windows
There are several
ways to read and write permanent SAS data sets. This tutorial presents a handy way to
do this in the Windows environment.
Creating a
Permanent a SAS Data Set in Windows
The technique for
creating a permanent SAS data set in Windows is straightforward. Instead of
using a temporary SAS data set name such as PEOPLE (or a permanent data file
such as MYLIB.PEOPLE) in the SAS DATA statement, use a complete Windows
filename.
Consider this SAS code:
DATA
“C:\SASDATA\PEOPLE”;
INPUT
ID $
1
SBP
2-4
DBP
5-7
GENDER $
8
AGE
9-10
WT
11-13;
DATALINES;
1120 80M15115
2130 70F25180
3140100M89170
4120 80F30150
5125 80F20110
;
RUN;
PROC
MEANS;
RUN;
This
code creates a data set called PEOPLE on your hard drive in the C:\SASDATA
folder, and the Window file name of this permanent file is PEOPLE.SAS7BDAT or
more precisely,
C:\SASDATA\PEOPLE.SASB7DAT
That is, instead of
using a SAS data set name directly, you can use a Windows filename. Thus,
Reading from a
permanent data set in Windows
If you already have a SAS data set on your hard drive -- (named for example
PEOPLE.SASB7DAT) anywhere on your system (could be local, network, flash drive,
etc) you can access that data set in a SAS procedure using the following
technique illustrated here: