Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
Some of the values on raw data file doesn’t have spaces or any other delimiter between all the values or period for missing data but value is found in same place or position in a data file. In this situation we can not use list input.
In order to read this type of data files we uses column input. In column INPUT we specify the position or range of the column data is available.
INPUT Name $ 1-10 Age 11-13;
Name variable from input file will be read from position 1 to position 10 and this is a character variable, you can see a $ symbol placed. Age will be read from position 11-13 and a numeric variable.
Example Input file :
Program to read the above file:
In this post we will be going through how to get your data into SAS from different data forms or data sources.
We can divide them into following categories
- Entering data directly into SAS data sets – You can feed data directly using DATALINES or CARDS statements. If you are using SAS EG, you can make use of data entry window.
- Creating SAS data sets from raw data files – SAS can read data from different type of raw file. This is the topic of broader discussion, we will be going in details.
- Converting other software’s data files into SAS data sets – We have multiple options for this. We can use PROC import procedure and the import wizard to convert Excel, Dbase, MSAccess file into sas dataset.
- Reading other software’s data files directly – SAS/ACCESS Engine products allows to read the data the data files directly. There are also data engines like SPSS allows to read the data directly.
Reading the data from raw data files
Reading the raw data separated by spaces
Example you have the following data in a raw file
Lucky 2.3 1.9 . 3.0
Spot 4.6 2.5 3.1 .5
Tubs 7.1 . . 3.8
Hop 4.5 3.2 1.9 2.6
Noisy 3.8 1.3 1.8
Winner 5.7 . . .
This data is separated by spaces. In order to read this data, we will write the following program
INPUT Name $ Weight Jump1 Jump2 Jump3;
PROC PRINT DATA = child;
In the above program SAS will recognise the space as it have to read the data into new variable. $ indicates you want to read a character variable. INFILE will try to read the variable until it reaches end of the files.
SAS Program –
A SAS program is a sequence of statements executed in order. A statement gives information or instructions to SAS and must be appropriately placed in the program.
There are few rules we need to follow when writing SAS programs. Every SAS statement ends with a semicolon.
- SAS statements can be in upper- or lowercase.
- Statements can continue on the next line (as long as you don’t split words in two).
- Statements can be on the same line as other statements.
- Statements can start in any column.
Like any other language you can use Comments in SAS program. We will have another detailed post for SAS comments.
Sample Program :-
Let’s say you want to read a file which have which have information about employee salary.
INPUT EMPID NAME $ GENDER $ SALARY;
PROC PRINT DATA=EMP; RUN;
Before we look into more details, let’s look into observation & variable
An observation is a collection of data values that usually relate to a single object.
A variable is the set of data values that describe a given characteristic. Variable are also called column.
Here’s an Example
SAS stores the data into SAS dataset.
Before you can analyse your data and produce a report with SAS software, the data must be in a
special form the SAS system can understand. This form is called SAS data set.
It consists of two portions:
- Descriptor Information
- Data Values
This describe the content information of a SAS dataset.
It contains following information
- Dataset name
- Date created/modified data
- SAS Version
- No of variables & Observations
- Info about each variable
- Variable name/data type/ length/position within the dataset and etc.
The Data values or the Data portion contains the actual data that have been collected. The data is
organized into a rectangular structure containing rows called observations and columns called
Base SAS software includes the DATA step programming for data access, data manipulation and
reporting using simple statistical and utility procedures. Must be installed on your system to run
most of the other SAS products.
Allows you access data used by other software packages. You can read and, in some cases, write
data in their native formats without having to leave SAS. Most of the popular database software is supported, and each has its own SAS/ACCESS product.
Allows you to write your own interactive SAS applications. Applications written with SAS/AF
software allow users quick-and-easy access to information without knowing the SAS language.
Is a menu-driven front end to SAS software. You make choices from menus, and SAS writes the program for you. Programs can be stored for later use.
Connects computers running SAS software. Data can be shared between the computers, and programs developed on one computer or operating environment can be transferred to another for processing.
SAS Enterprise Guide
Providing a graphical user interface to power SAS. This is a Windows only product, but can be used to access SAS servers on other systems.
SAS Enterprise Miner
A data mining tool and it is a complete product in itself. It provides an easy-to-use front-end to the SEMMA (Sample, Explore, Modify, Model, Assess) process for business users.
Produces high-resolution plots, charts, and maps.
Allows you to save data in multidimensional database (MDDB) formats for use with online analytical processing (OLAP) (otherwise known as slicing and dicing your data).
Statistical analysis with a number of procedures, providing statistical information such as analysis
of variance, regression, multivariate analysis, and categorical data analysis.
SAS Visual Analytics
Includes both a suite of business intelligence (BI) tools and a platform to provide uniform access to data. The goal of this product is to compete with the popular reporting tools like Business Objects and Cognos. SAS® Business Intelligence or Visual Analytics tool gives you the information when you need it, in the format you need. The SAS Difference Other vendors provide business intelligence solely in the form of historical reports that give you hindsight but limited insight. SAS Business Intelligence allows you to understand the past, monitor the present and predict outcomes as you move your business ahead.