hnk
SAS Tutorial

SAS programming tutorial provides basic and advanced concepts of Statistical Analysis Software and its programming language. Our SAS programming tutorial is designed for professionals and as well as beginners.

Today, we’ll start a replacement journey of SAS technology with the assistance of a comprehensive SAS tutorial. There are various questions which arise in our mind once we see the word ‘SAS’ like, what’s SAS? Where is it used? What is the future scope in technology? You will get all the answers for such similar questions during this SAS tutorial.

Let’s quickly start by exploring the essential concept of SAS programming.

Prerequisite

Before learning SAS, you should have basic knowledge of business requirements, computer functionality, analytics and basics of any programming language

Audience

Our SAS tutorial is designed for beginners and professionals.

Problems

We assure you that you will not find any problem in this SAS Tutorial. But if there’s any mistake, please post the matter within the contact form.

 Introduction to SAS Programming

We require some statistical tools to handle the tonnes of knowledge generated every day. Structuring and analyzing the info is the main task, followed by strategic deciding. It is often directly said that the cause and more than data, led to the efficient generation of knowledge analysis tools like SAS.

SAS programming language is defined because of the science of data-driven deciding. Technology can bring us from raw data to structured readable data; it even predicts many solutions to a problem. But it is ultimately the call of humans to make the final decision. It uses the tedious and procedural exploration of old data to hold business resolution.

Let’s see this with an example, have you ever wondered, why is a billing point at the mall, loaded with gum and candies on its sides.

This is not an unplanned move, rather a strategically made decision. Let’s see how, for instance when parents are at the billing counter with their kids, waiting for their turn. The gums and candies lure the kids and they demand to have it. To prevent creating a scene at the counter, the oldsters need to unwillingly pip out. This results in an increased sale of candies and gum. This is what business analytics does, observes the trends and patterns and mould the business accordingly to make a profit.l.

What is SAS Programming?

SAS is a widely used software for Data Analytics. It is a software suite which will alter, mine, manage and retrieve data from different sources and perform statistical analysis thereon. It is also used for data management, statistical analysis, report writing, business modelling, application development, and data warehousing. This is a helpful tool through which you can use qualitative techniques and procedures that allow you to increase employee productivity and business profit.

In SAS, data is extracted and categorized in tables which helps you to identify and analyze data patterns. Besides, SAS is a platform-independent software, which means that you can run SAS on any operating system like Linux, Windows, Mac, Ubuntu etc.

SAS Image

Most common definitions:

SAS program

The SAS program contains a data phase to retrieve and manipulate data, and the PROC phase to analyze data. There is a series of statements in each phase. The DATA phase contains executable statements that are responsible for the actions taken by software and the declarative statement that provides instructions for reading data sets or changing the format of the data.

DATA Phase

There are two steps in the DATA phase: compilation and execution. In the compilation phase, syntax errors are identified, and declarative statements are processed. Later, in the execution phase, each executable statement is processed sequentially. The data set is organized into tables with the columns and rows.

Macros

Data of SAS can be published in PDF, HTML, Excel and other formats via the output delivery system, which was first introduced in 2007.

The SAS software suite contains more than 200 components; some are given below.

  • SAS/STAT – Statistical analysis
  • SAS/OR – Operations research
  • Base – Basic procedures and data management
  • IML – Interactive matrix language
  • SAS/INSIGHT – Data mining
  • SAS/QC – Quality control
  • SAS/GRAPH – Graphics and presentation
  • EBI – Suite of Business Intelligence Applications
  • Enterprise Miner – data mining
  • ETS – Econometrics and Time Series Analysis
  • SAS/AF – Applications facility
  • SAS/PH-Clinical trial analysis
  • Enterprise pattern – GUI based code editor & project manager
  • SAS Grid Manager – Manager of SAS grid computing domain

 Components of SAS Programming

We’ll learn components of SAS:

 i.Base SAS

It is a basis for all SAS software. SAS has hardware deft and combines into any computer environment. It is easy to learn. It supplies data ease in data readability and interpretation.

 ii. SAS/GRAPH

It is a data visualization technique. It helps represent structured data into graphs by enhancing the process of interpretation.

 iii. SAS/STAT

It helps us perform various statistical analysis  variance, regression, and psychometric analysis. Some statistical techniques such as ANOVA procedures are specially strung in the SAS environment

 iv.SAS/ETS

It is specially used for forecasting and for the time series analysis.

 v. SAS/IML

IML is called Interactive Matrix Language.

 vi. SAS/INSIGHTS and Enterprise Miner

SAS/INSIGHTS and Enterprise Miner are used for data processing.

SAS insights

Building Blocks of SAS Programming

 DATA helps to build a data set. The PROC refers to a Procedure. It processes the data. Now, as an example , consider if I wish to convert $ into Rs. So, if i exploit SAS for this conversion, then the info converts dollars to rupees and creates a dataset named ‘currency’. The PROC will print the result for us.

Statements are made from PROC and DATA steps. DATA steps are responsible to read data, on the opposite hand, PROC steps are wont to perform utility functions, analysis of knowledge , or print reports.

SAS studio

Writing DATA and PROC steps

SAS data results

Results obtained

Features of SAS Programming Language

SAS is the pioneer in data analytics because of its beneficial features.

We can transport SAS in the various computing environments, and it works exactly the same on all platforms, except for an interactive window. The key features of SAS Programming Language are given below:

Strong data analysis

  1. Strong Data Analysis Abilities

Strong Data Analysis Ability is the first feature of SAS software and programming language. SAS is like a complete package for the data analysis section. Its analysis ranges from simple figures to advanced levels.

The best part about SAS software is the Inbuilt Library because there are all necessary packages required for analysis and reporting of data.

  1. Flexible 4 Generation Programming Language (4GL)

SAS is a 4GL programming language, and that is its essential feature because the SAS programming language has an easy-to-learn syntax. More than that the code of SAS programming language is like statements, and these statements are clear and concise instructions to the systems.

 Inbuilt libraries of SAS have reduced coding for common applications to provide an opportunity to modularize our job. It is also user-friendly for non-programming users.

SAS is an interactive language. Its log window is like a mirror that keeps giving instructions to the user. It provides notes and marks error. There is also DS2, which helps in data manipulation. Complex data can be manipulated in its place in the database. 

  1. SAS Studio

SAS Studio is a unique feature among SAS features. We can easily access SAS Studio from any device and with any web browser. There is no need for client installation. All libraries and data files that are needed in the SAS program can be accessed through any web browser.

It is very instructive. As soon as someone starts typing, the autocomplete feature gives us indications of various procedures. For further guidance, pop-up syntax and parameter list are displayed.

It also helps you to create and add personalized code snippets and add them to the snippet library. We can point and click the interface; it guides us during the analysis process at different levels

  1. Support for Various Data Format

Support for different data formats is another feature of SAS. SAS has the ability to read data from any type of file, any format, and even from files with missing data.

SAS provides support for SQL. It has an extensive database of character encoding; there is full support for the most commonly used languages. SAS programming language also maintains singularity, so that SAS works with data in many languages.

  1. Management

SAS management is one of the significant features of SAS software. It has an SAS Environmental Manager that alerts, monitors and manages the analytics environment. The Extended Java Graphical User Interface administers SAS functions in SAS Management Console.

We can also execute a failed program entirely within the restart mode. It starts again from the same stage where the program failed.

XML Engines have many functions like importing and exporting XML documents and creating XML maps.

Application Response Measurement Interface looks at various applications and checks for the availability of transactions.

  1. Report Output Format

SAS is capable of displaying analytical results and the number of reporting options. Base SAS 9.4 has high-quality graphics such as ODS statistical graphics, ODS graphics designers and editors, etc.

We can save and create reports in standard formats such as RTF, PowerPoint, and pdf. We can also save them as eBooks and i-books; this gives us the luxury of visual analytics.

We can customize the output according to the hierarchy of customer requirements. The output can be ported to different places.

  1. Data Encryption Algorithms

SAS ensures that security holds the essence of how we provide access and for that SAS 9.4 has a security feature called SAS / SECURE. We can also encrypt SAS data on the disk between different algorithms.

So, it was all about SAS characteristics. Hope you like our explanation.

Summary

In this SAS feature, we have studied that SAS programming is a complete package for any type of statistical work. It also provides service support in all platforms except one. The libraries in the SAS include all those that are generally necessary for analysis. Its encryption feature makes it secure and portable for various devices. Besides, if still, you have any questions about SAS attributes, feel free to ask in the comments section.

 SAS Windows

Initially, the SAS window was an equivalent for all operating systems. But now with changing time, the SAS window looks different on different operating systems like Windows, MAC, etc. This provides a scope for personalisation of the SAS environment. However, there are many common elements in various operating environments.

Now, in SAS Programming Tutorial, we’ll cover the SAS Windows in detail:

i.Editor

This is a text editor window to type, edit and submit SAS programs and also process data files. Its features vary according to different versions and operating environments.

ii.Log

After submission, various notes, errors, etc. are displayed here. Even it provides warnings with program statements here.

iii. Output

It provides the printable versions of our results here.

iv.Results

The resulting window shows a table of contents for our output window; we will see an inventory of leads to an overview format.

v.Explorer

This window acts as a shortcut to succeed in SAS files and libraries.

SAS tutorial

Data Libraries in SAS Programming

We can understand it with a very basic example. Before you make tea, it is important for you to know where all the ingredients are? SAS Programming libraries are the situation where the SAS data sets are stored. The format of SAS libraries depends totally on the operating environment. This is one among the simplest features of SAS Programming. Availability of various libraries makes it very easy to perform a statistical function. In the new SAS, studio libraries are present within the navigation panel.

SAS Help failure

Various inbuilt libraries in SAS Programming Language.

We can download the university SAS edition from sas.com

SAS Applications

Multivariate Analysis | Business Intelligence |Predictive Analytics | Clinical Research and Forecasting

SAS initially designed to complete statistical analysis but now it is also used for analytics. It is mainly used for processing complex raw data into meaningful information. This meaningful information helps an institution to make better decisions. It is also helpful to us to compile, analyze and extract data from various resources. It does the processing, cleaning, digging, and packaging for statistical people.

SAS application

In general, the SAS tool is playing a crucial role in statistical analysis and decision-making. But here we are presenting some specific fields that primarily use the SAS software.

So, let’s proceed..

  1. Multivariate Analysis

Multivariate Analysis is used to analyze multiple elements or variables at the same time. SAS investigates the relationship among various variables without categorising them as dependent or independent. It uses different studies that reflect the effect of variable factors on a single result. It includes analysis of factor, bivariate, and many regressions.

  1. Business Intelligence

Business intelligence is linked to the technologies and procedure that are hired by any enterprise for data study of business information. Analysis of data helps the senior team by providing the scope of decision making. It also provides intuition regarding current, predictive and historical views of business working.

  1. Predictive Analytics

Predictive analytics uses statistical algorithms, data and machine learning to identify the possibility of future outcomes based on historical data. As the name suggests, Predictive analytics uses already available data for future prediction. There are various statistical techniques to draw inferences for the prediction.

For example, a product of a company continues the trend in sales over the last few years, by analyzing the sales data of the product, it is predicted that the demand of the product will not change. Now, if another product of the same company continues the sales trend of changing demand every month, by analyzing all the factors such as reason behind variation, conclusions, customer feedback process, It is predicted that there is high risk in the product. In the case of such products, historical data cannot be used for sales prediction.

  1. Clinical Research and Forecasting

In the field of medicine, there are revolutionary changes due to SAS. It is used in the diagnostic decision-making system. SAS helps in critical decision making such as in diagnosis and prognosis, both are vital elements of medicine and must be precise and accurate. SAS is used to see if patients are at risk or not. SAS tool is even used in finding little chances which can improve the condition of a patient.

 Summary

In all the above-mentioned applications, SAS uses statistics to analyze the data and produce the results. Its specific application produces accurate results in various fields. In the multivariate analysis, it analyzes multiple elements or variables at the same time.

So, the overall conclusion is that SAS is the pioneer in data analytics with its vast area of applications. We explained all the applications very clearly but if you still have any query, feel free to ask in our contact section.

SAS v/s R v/s Python

SAS Programming is one of the senior tools used for the study. But over time many other tools have come into the market. Often used data study software is SPSS, R, MATLAB, Rapid Miner, Weka, SAP, Minitab, Apache Mahout, Statistica, etc. This section will mainly specialise in a comparison between SAS, R, and Python.

i.Cost and Availability

SAS

       SAS being the closed source is quite expensive. It is professionally available if the company has bought access.

R Programming

       R programming is open-source software and is available free of cost in its entire version.

Python

       Similarly, Python is open-source software and it is available free of cost in its entire version.

ii.Ease of learning

SAS

       It is very easy to learn, it also provides a GUI for the non- programming community. A huge database consisting of books, tutorials, videos, etc. are readily available.

R Programming

       R requires you to have a thorough understanding of coding. It is low-level programming and needs a string coding hand.

Python

       It is one of the simplest programming languages. It lacks a GUI for ease of non-programmers.

iii. Graphical Capabilities

SAS

      It has functional graphical support but fails to supply any customization. A student must have a radical knowledge of varied graphical packages.

R Programming

      R has advanced graphical features. This makes it easy for intense and diversified graphical implications and inferences.

Python

      Python has advanced graphical features. This makes it easy for intense and diversified graphical implications and inferences.

iv.Improvisation in tools

SAS

      SAS gives out its new features in every remake. It liberates it in closed space, so these are well tested by experts. However, there is no new update every now and then.

R Programming

      As R is open-source, it’s updated quickly on a frequent basis. However, thanks to open access, it’s even susceptible to more errors.

Python

       As Python is open-source, it modernizes quickly on a frequent basis. However, thanks to open access, it’s even susceptible to more errors.

v.Customer support and guidance

SAS

      It is very high and established. Being a closed source, all of your problems are handled professionally.

R Programming

      R is open source there lacks quality in the customer care segment. But it has online communities that can help you.

Python

       Python is open source due to which it lacks in the customer care segment. But it has online communities that can help you.

So, this was all about the SAS Tutorial. Hope you like our explanation.

Summary

We studied SAS programming which may be a statistical language for mining and converting data into a legible and interpretable format. We use it in business analytics to make strategic decisions. SAS programs are sequential statements that we write in an orderly manner. We can write SAS declarations easily in English declaration to direct the system. In short, we studied an entire guide or a cheat sheet for the SAS Programming Tutorial.

Differences between SAS and R

Although both SAS and R is a widely used language in the field of data science, there are some notable differences which make them different from each other.

Sr.no.

Parameters

SAS

R

1

Objective

SAS is a specific programming language designed primarily for statistical analysis of data from spreadsheets or databases.

R programming language is widely used among statisticians and data miners to develop statistical software and data analysis.

2

Ease of Learning

Learning is easier than R because no programming knowledge is required. We can learn it with limited knowledge of SQL.

Learning is less easy than SAS because it contains tedious and lengthy code.

3

Statistical Ability

SAS provides a powerful package that offers all types of statistical analysis and techniques.

R is an open source tool that allows users to submit their own package/library. The present day technologies are often released in R First.

4

Cost

SAS is expensive commercial software.

R is an open source free software.

5

Graphical Capability

SAS has limited graphical support, Although there are some graphical capabilities in Base SAS, these abilities are not widely known, and therefore R gets a clear edge in this aspect.

R is advanced in graphical visualization, due to the availability of various packages such as ggplot, latis, and RGIS.

6

Data Publishing

SAS supports data publishing in HTML, PDF, Excel, and other formats via the Output Delivery System.

R supports data publishing either in soft or hard copy.

7

File Sharing Capability

We cannot share SAS generated files with other users who do not have SAS Software.

Since R is an open source free software so that anyone can install it and use shared files.

8

Software Updates

SAS does not update frequently.

R is an open source software, so it continues the update.

9

Customer Support

SAS provides a huge and dedicated customer support

R has no customer service support. However, the most significant online communities support it.

10

Core Learning Support

Core learning in SAS software is still in its early stages, and there is a lot of work to do before it gets mature.

R provides great integrations for core learning.

11

Sharing of Market

Market share of SAS is facing crucial competition with R and other data analytical tools.

R is growing at high speed since the last five years because of its regular updates and integrated features.

12

Job Market

SAS software is the market leader in providing employment. Many large-scale companies prefer SAS for data analytics.

R is also providing a large number of jobs, and there has been a significant increase in the number of jobs in the last few years.

 SAS Intelligence Platform Architecture

SAS Intelligence Platform Architecture is designed to access large numbers of data efficiently, as well as provides timely intelligence to a great number of users simultaneously.

The platform follows a three-tier architecture that enables you to distribute functionality in computer resources so that each type of work can be done by those resources that are most suitable for the job.

You can easily examine the architecture to determine whether it meets the demands of your workload or not. For a large company, tiers can be installed in several machines with different operating systems, and for demonstrations, prototyping or very small enterprises, all the tires can be installed on a single machine.

As shown in the following SAS Architecture Diagram, the SAS Information Delivery Portal is implemented using a three-tier architecture. This architecture has proved to be highly effective for developing and deploying enterprise applications.

SAS intelligence

Architecture Components of SAS software are listed below.

Client Tier

The client tier is used to view the portal and its content. It includes all the components that are used to view the portal and content. The client tier includes a web browser that is used to interact with the portal over HTTP (HyperText Transfer Protocol) OR HTTP/S (HyperText Transmission Protocol, Secure). These HTTP or HTTP/S protocols makes the SAS Information Delivery Portal “firewall friendly.” The portal can be deployed anywhere on the network and users can access it from any internet connectivity like corporate intranet, extranet, or public internet.

Depending on the content, the client can also use one or more standard desktop applications such as Adobe Acrobat Reader or Microsoft Excel. These applications are used in the process of view content. The content is streamed by the servlets in the middle tier of the portal.

When the web browser receives such content that it does not know how to present it, it looks at the mime-type of content and tries to find a viewer that knows how to display it. Standard Web browser functionality redirects the stream of content to the appropriate viewer for displaying. Once the content comes under one of these applications, the user can process it locally or save it to disk.

There is also another optional client application that is the SAS Package Reader. SAS Package Reader is part of the SAS Publishing Framework. The Package Reader enables the user to view and manage the contents of a SAS package off-line, independent of the portal Web application.

client tier

Middle Tier

The middle tier is a center of SAS architecture which provides a centralized access point for enterprise information. All direct access to content is processed by the components that are operating in this tier. This design point offers several advantages.

By separating business logic from display logic, you can use different clients to take advantage of logic at the middle tier. One more advantage is that the centralized point of access makes it easy to implement security rules, administer the portal and manage code changes.

The following functions are hosted by the middle tier:middle tier

Web Tier

The first part of the middle tier is the web tier that contains Web Application Portal for SAS Information Delivery.

Web Application Portal

SAS Information Delivery Portal is a collection of web applications, Java Servlets, JSP, JavaBinx and other sections and resources. These components work together to access the information stored in the Enterprise Directory and present a customizable interface for the user.

Servlet container

The servlet container or servlet engine is responsible for the management of the SAS Information Distribution Portal web application. Servlet Container or engine provides a runtime environment that supports deployment, concurrency, life-cycle management, and other services for Java components.

Web server

The web server provides services for the servlet engine. For example, the servlet engine depends on the HTTP server so that it can provide HTTP message handling. Web servers can also be used to host web sites that can be accessed through the portal.

Back Tier

The back tier is the third and last part of SAS architecture. This tier provides runtime environment to Data Servers and Compute Servers. A computer server can also have business objects. For example, SAS IOM servers contain SAS stored processes that analyze the data and summarize the results. As shown in the above figure, the SAS Information Delivery Portal uses standard interfaces like JDBC and Java IDL to communicate and access data from IOM servers.

Back tier contains two servers, one is the IOM Server that we have explained above, and another is the Enterprise Directory Server. According to the description of the Single Access Point for Enterprise Information, the Enterprise Directory Server stores metadata about the content that is located in the entire enterprise. The directory does not have content, and it contains only metadata that describes it. It contains the location of the information and how to access it, and how it relates to other content items. Web application portal uses JNDI (Java Naming and Directory Interface) to access the enterprise directory server.

Back tier

Back Tier does not necessarily translate into additional hardware platforms. For small implementations, these servers can run on a machine similar to a web server. On the other hand, a large enterprise can have many compute and data servers and can be an enterprise directory that is distributed on many platforms. The architecture of the SAS Information Delivery Portal gives you the flexibility to distribute these functions as per the need.

Advantages | Disadvantages of SAS Programming Language

We have discussed features of the SAS programming language in the previous tutorial. In this tutorial, we will discuss the various advantages and disadvantages of the SAS programming language.

So, let’s proceed ..

Advantages of SAS

There are several advantages of SAS Programming Language:

  1. Easy to learn

SAS is very easy to learn syntax. It can be learned easily without any programming skill so that anyone can learn it. Coding of SAS is in the form of simple statements. It is like giving instructions to the machine what to do.

  1. Ability to handle Large Database

SAS is strongly capable of handling large databases very easily.

  1. Easy to Debug

SAS is a very comprehensible language. The process of debugging is very easy. It is easy to understand and correct the error because the log window states it clearly.

  1. Tested Algorithms

The algorithm implemented in the SAS program is fully tested and analyzed by developers. Every version of SAS is tested in a controlled environment, before its release. Testing is possible because SAS is a closed source language.

  1. SAS Customer Support

The organization of SAS maintains proper monitoring, as it is like a complete organization to analyze SAS. It has intuitive customer support. SAS customer support handles all kinds of problems.

  1. Data Security

SAS software is a primary tool for many large scale companies. Company’s data is confidential here that’s why it is a close source of companies.

No external tincture is possible. Because SAS is a closed source tool, it can only be edited by the SAS organization.

In the extension of the above point, the data in SAS is completely secure. In the case of office use, without license we cannot extract data. Manipulation is not possible because of Data security, and this is the reason behind its popularity in the corporate world.

SAS is preferred over R and any other language used for analysis. R is open source; therefore, data security is not guaranteed. Only freelancers use the R.

  1. SAS GUI

SAS is a language that has made statistical computing easier for non-programming users. It has an amazing GUI (Graphical User Interface). Its user interface has various tools like plots, graphs, and highly versatile libraries.

  1. Output

SAS has been developed in a long period of time. That’s why it provides a well formatted and absolutely correct output, which is easy to understand.

  1. Huge Job Prospects

Due to the fact that SAS has been used in the industry for a very long time, there are huge employment potentials. Professionals learn SAS as a condition so that they can enter the analytics industry. The person who commands the SAS can easily learn R and Python. This is a market leader in the Analytics industry.

Disadvantages of SAS

Some major disadvantages of SAS programming are as follows

  1. Cost

The cost of SAS software is one of its major disadvantages. We cannot use all its functions without a license, which is very expensive.It is a complete software due to being in a closed environment, so there is no facility for the license of any single function that we need. All these prerequisites make it very expensive.

  1. SAS is Not Open Source

R is always quicker than SAS in implementing an algorithm related to machine learning. The reason behind this, R is open-source so that anyone can operate it, but this is unfavourable for SAS. SAS is a closed environment software, and it doesn’t support open source, so the algorithm of SAS procedures is not for the use of the public. SAS is available only in the licensed version. Algorithms are not openly available for public research.

  1. Lack of Graphic Representation

There is more availability of R for advanced graphics. Its graphics presentation is much more vivid and consistent than SAS. It has a more descriptive plot, diagram, and graph.

  1. Difficult Text Mining

Text mining in R is free, but in SAS, it uses SAS Enterprise. Text mining means extracting information from text. This is used to decrypt a written code. It tells us what the written text can decide in terms of decision making. This is the process in which the text converts data into decision making and analysis.

  1. Difficult than R

SAS is more procedural language than R. There are more lines of code in SAS than R.

We can quickly apply new innovations such as statistical learning and machine learning in R in comparison to SAS.

Many packages which are free in R, are chargeable in SAS. For example, Text Mining, Time Series Forecasting (SAS / ETS), etc.

Summary

Since there are various advantages and disadvantages of SAS Programming. But in the Field of analytics, SAS has its own popularity among other languages. It has a wide job market, more security than any other language and a close source language. SAS has a protected environment for developers to test algorithms. It is always bug-free and has very helpful customer support.

SAS Terminology

In this SAS terminology tutorial, we are providing a list of important SAS terminology that will come to you during learning SAS. Before starting SAS terminology, you can modify the concept of the SAS programming language first.

Here we are going to discuss SAS terminologies, which are helpful in data science and used in SAS programming. SAS is used for advanced analytics, predictive analytics, data management, business intelligence, and multivariate analysis.

Different SAS Terminologies

Access Descriptor

SAS interacts with IMS databases through an interface view engine. Interface view engine uses SAS / ACCESS descriptor files, created with the ACCESS procedure. There are two types of descriptor files:

  • Access descriptors
  • View descriptors

Access Descriptor

Access descriptor contains information of the IMS (Information Management System) database to be used. The information of the database includes the IMS field name, database format, database name, section name and length, key fields and default SAS format. An access descriptor contains a special handling idea for a field, and it indicates whether an entity occurs multiple times in a database segment or not. The SAS / ACCESS file describes data for the SAS software, and this data is present in a PC file.

An access descriptor toil as a master descriptor file because it includes an entire description of the database whereas IMS does not store descriptive information about a database.

View Descriptor

View descriptor is used to define data in subsets. It defines subsets only of access descriptor described data. View descriptor is used in the SAS program, to write or read data directly in the IMS database. By using view descriptors IMS data can be extracted and placed in a SAS data file.

Data Type

Inside a table, each column has one attribute and the data type which indicates operating environment, the capacity of physical storage and type of data (like int, Boolean, String etc.) present in the column.

There are only two data types that are used in the SAS: the real number and fixed-length strings of character. Real numbers are used to store dates and time internally as numbers and characters are always as macro variables. Value of character should be cited to separate them from other language elements like variables.

Column

It is a vertical component of the PC file which has a unique name and specific type data with certain attributes. A column corresponds to a variable in the SAS terminology.

Column Function

Column function is an operation that calculates each value of the column. For example, salary is a column function of a column, which needs to be calculated.

Data Value

In SAS software, the data value is a unit of character or numeric information that is presented in a SAS data set. A data value represents a variable in an observation.

Browsing Data

Browsing data is a process of viewing data of the file which contains observations.

File

File is a collection of entities that are related to each other in a well-organized manner. Each record is treated as a unit and controlled through SAS software. These SAS files are processed and stored in the SAS Data Library.

Format Data Sets

Sometimes we prefer to represent the analyzed data into a format which is different from the original format present in the data set. For example, in a text variable, there are all text values in lowercase, and we want to represent these values in uppercase. Or we need to add decimal places in a variable that contains price information. To do so, SAS provides FORMAT Statement.

The FORMAT statement contains SAS-inbuilt-formats. We can apply the FORMAT statement to use in-built formats and the PROC FORMAT in a user-defined format.

Syntax:

FORMAT variable name format name; 

Where,

FORMAT: It is a FORMAT Statement which indicates the action of formatting.

Variable name: This is the name of the variable that needs to be formatted.

Format name: It is the name of SAS-in-built format to be applied on the variable.

Example:

Let’s consider the SAS data set employee containing details of the employees of an organization. Here we need to show the names of employees in uppercase, to do that we are using the FORMAT Statement upcase9, which is SAS-inbuilt-format.

DATA employee;

Input empid name$ age weight salary; 

FORMAT name$ upcase9.; 

datalines;   

1 Akash 22 64 22000 

6 Jaya 55 63 23500 

2 Vinita 34 68 33000 

7 Kumar 43 64 27000   

4 Anita 29 65 53000 

5 Taufik 21 45 32000   

8 Boby 32 71 25000 

3 Ankita 40 69 42000   

;   

run; 

   PROC PRINT DATA = employee;  

run; 

Execute the above code in SAS studio:

INPUT SAS

Output:

output SAS

As you can see in the output, all the names of employees have converted into uppercase.

Using PROC FORMAT

PROC FORMAT is used to format user-defined data. We can format data values or observations as per our requirement. In the example given below, we applied both inbuilt and user-defined format statements.

The inbuilt format upcase9 is used to convert lowercase text into uppercase. For user-defined formatting, we changed values of the variable dept from abbreviations to an expanded form, i.e., IT = Information Technology and HR=Human Resources.

DATA employee; 

   INPUT empid name $ salary dept $;  

DATALINES;  

1 Akash 22000 IT 

6 Jaya 23500 HR   

2 Vinita 33000 IT   

7 Kumar 27000 IT  

4 Anita 53000 HR   

5 Taufik 32000 IT   

8 Boby 25000 IT    

3 Ankita 42000 IT  

proc format; 

value $DEP ‘IT’ = ‘Information Technology’ 

      ‘HR’= ‘Human Resources’; 

RUN; 

   PROC PRINT DATA = employee;  

format name $upcase9. DEPT $DEP.;  

RUN; 

Execute the above code in SAS studio:

INPUT PROC

Output:

OUTPUT PROC

As you can see in the output, all names of employees have been converted into uppercase, and abbreviations of the department have been converted into expanded form

SAS Operators

In the SAS, operators are the symbols, which are used to perform calculations like addition, multiplication, subtraction, division, comparison, etc. These symbols are an in-built part of SAS programming language, so we can combine these symbols in a single expression to get the desired output.

There are five types of operators in the SAS:

  • Arithmetic Operators
  • Logical Operators
  • Comparison Operators
  • Minimum/Maximum Operators
  • Precedence Operator

Arithmetic Operators:

Arithmetic operators are used to perform mathematical calculations like addition, multiplication, subtraction, division, etc. The following table describes arithmetic operators with their operations.

Operator

Description

Example

+

Addition

12+2=14

Subtraction

24-4=10

*

Multiplication

6*3=32

/

Division

46/23=2

**

Exponentiation

2**3=8

Let’s understand through an example, how we can use arithmetic operators in the SAS programming.

DATA Airthmatic_Operator; 

input @1 A1 [email protected] A2 3.1;  

Add_result = A1+A2; 

Sub_result = A1-A2; 

Mult_result = A1*A2; 

Div_result = A1/A2; 

Expo_result = A1**A2; 

datalines; 

11.21 5.3 

3.11  11 

PROC PRINT DATA = Airthmatic_Operator; 

RUN; 

Execute the above code in SAS studio:

airthmatic input

Output:

airthmatic output

As we can see in the output, all values have been calculated according to the arithmetic operators.

Logical Operators

Logical operators are used to evaluate the truth or false value of an expression.The result of logical operator is always Boolean value, i.e., 1 or 0. The following table describes logical operators with their operations.

Operator

Description

Example

&

This symbol is called the AND Operator. If both data values evaluate true, then the result is 1 else it is 0.

(5>2 & 2> 3) gives 0 or false.

|

This symbol is called the OR Operator. If any one of the data values evaluates true, then the result is 1 else it is 0.

(10>9 & 5> 3) gives 1 or true.

~

This symbol is called The NOT Operator. If the values evaluate false, then the result is 1 else, it is 0.

NOT(8> 3) is 1 or true.

Let’s understand through an example, how we can use logical operators in SAS programming.

DATA Logical_Operator; 

input @1 a1 5.2 @7 a2 4.1;  

and_=(a1 > 10 & a2 > 5 ); 

or_ = (a1 > 12 | a2 > 15 ); 

not_ = ~( a2 > 7 ); 

datalines; 

11.21 5.3 

3.11  11.4 

PROC PRINT DATA = Logical_Operator; 

RUN; 

Execute the above code in SAS studio:

logical operator input

Output:

logical operator output

As we can see in the output, all values are producing Boolean results according to the evaluation of logical operators.

Comparison Operators

Comparison operators are used to compare the values on the basis of equality. The result of the comparison operator is always a Boolean value, i.e., 1(for true) or 0 (for false). The following table describes comparison operators with their operations.

Operator

Description

Example

=

This symbol is called the EQUAL Operator. If both values are equal, then the result is 1 else it is 0.

(8 =8) gives 1. (4=8) gives 0.

^=

This symbol is called the NOT EQUAL Operator. If both values are unequal, then the result is 1 else it is 0.

(3 ^= 5) gives 1. (5^= 5) gives 0.

This symbol is called the LESS THAN Operator.

(2 < 9) gives 1. (12 < 9) gives 0.

<=

This symbol is called the LESS THAN or EQUAL TO Operator.

(3<= 4) gives 1. (4 <= 4) gives 1. (7 <= 4) gives 0.

This symbol is called the GREATER THAN Operator.

(22 > 20) gives 1. (10 > 20) gives 0.

>=

This symbol is called the GREATER THAN or EQUAL TO Operator.

(10 >=5) gives 1. (5 >=5) gives 1. (3 >=5) gives 0.

IN

If the value is equal to any of the values in a given list, then it returns 1 else returns 0.

9 in (5,7,9,8) gives 1. 2 in (5,7,9,8) gives 0.

Let’s understand through an example, how we can use comparison operators in SAS programming.

DATA Comparison_Operator; 

input @1 a1 5.2 @7 a2 4.1;  

EQ_ = (a1 = 11.21); 

NEQ_= (a1 ^= 11.21); 

GT_ = (a2 => 8); 

LT_ = (a2 <= 12); 

IN_ = a2 in( 6.2,5.3,12 ); 

datalines; 

11.21 5.3 

3.11  11.4 

PROC PRINT DATA = Comparison_Operator; 

RUN; 

Execute the above code in SAS studio:

comparison input

Output:

comparison output

As we can see in the output, all values are producing Boolean results according to the evaluation of comparison operators.

Minimum/Maximum Operators

These operators are used to compare the values of the variable across the row to return the maximum or minimum value from the list of values in the row.The following table describes Minimum/Maximum Operators with their operations.

Operator

Description

Example

MIN

This group of alphabets is called theMIN Operator. It returns the minimum value from the entire row.

MIN(45.2,11.6,15.41) gives 11.6

MIN

This group of alphabets is called theMAX Operator. It returns the maximum value from the entire row.

MAX(46.3,11.6,15.41) gives 46.3

DATA MYDATA1; 

input @1 A1 5.2 @7 A2 4.1 @12 A3 6.3;  

min_ = MIN(A1 , A2 , A3); 

max_ = MAX( A1, A2 , A3); 

datalines; 

10.21 5.3 29.12 

3.11  11.4 18.12 

PROC PRINT DATA = MYDATA1; 

RUN; 

Execute the above code in SAS studio:

my data input

Output:

my data output

As we can see in the output, minimum and maximum operators have returned the minimum and maximum values from the list of values in both rows.

Concatenation Operator

Concatenation Operator is used to concatenate two or more string values. The following table describes the Concatenation Operator with its operation.

Operator

Description

Example

||

This symbol is called the concatenation Operator. It concatenates two or more string values.

‘Hello’||’ SAS gives Hello SAS

DATA Concatenate_operator; 

input  A1 $ A2 $;  

concat_ = (A1 || A2); 

datalines; 

Hello World 

Hello SAS 

PROC PRINT DATA = Concatenate_operator; 

RUN; 

Execute the above code in SAS studio:

concatenate input

Output:

concatenate output

As we can see in the output, both string variables have been concatenated.

Precedence Operator:

Precedence Operator is a group of operators which indicates the order of evaluation in the case when multiple operators present in a complex expression.The following table describes Precedence Operators with their operations.

Group

Order

Symbols

Group I

Right to Left

** + – NOT MIN or MAX

Group II

Left to Right

* /

Group III

Left to Right

+ –

Group IV

Left to Right

||

Group V

Left to Right

<<= = >= >

If you have any query about SAS Tutorial, feel free to ask in the comment section.

0 Reviews

Write a Review

WhatsApp chat

Schedule a demo

We will schedule the demo with an expert trainer as per your time convenience.

Have a query?

we'd love to assist and help you on anything related to IT courses.