EDUCBA

EDUCBA

MENUMENU
  • Blog
  • Free Courses
  • All Courses
  • All in One Bundle
  • Login
Home Data Science Data Science Tutorials SAS Tutorial SAS Array

SAS Array

Updated March 16, 2023

Introduction to SAS Array

The arrays in SAS are mainly used to store and retrieve the values using the index value format to represent the data location. Depending upon the reserved memory areas, array-name is defined as the array followed by the same set of rules applicable for the variable names subscript is the number of input values used in the array.

SAS Array

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

What is SAS Array?

It is the most important and convenient way for temporary usage. It identifies the variable groups with data processing along with the data steps, which the data programmers already define for performing the same number of tasks with related variables using the array elements that define the name of the elements. It has been fetched, and select the data range of the elements with all sets of variables that started with the start and end type of variables of the same type.

We can create the SAS of the elements with a specified set of arrays on the SAS code. Array statement will use and start the Array keyword for declaring the SAS to define the new array for the length and some additional parameters. But the array must be the valid SAS name followed by the maximum set of characters like 32, and it starts with the letter or underscore of the subsequent characters of alphanumeric characters. It does not contain the blank value nor a special set of characters except the underscores and other special characters. So that besides, the array name with a valid SAS name can’t have the same name for any of the variables on the dataset and should not give the array with the same set of names for the existing SAS function.

How to Create and Use SAS Array?

Mainly SAS arrays are used for storing and retrieving the datas with a series set of values of the index range. The index represents the location and reserves the shared memory areas for the subscript of the optional parameters for storing the character set of values. The variable set of lists is used in the optional set of variables stored in the placeholders for array values that can be set as the actual values stored in the array for a declaration from the file format for both reads and write operations on the data line. The array statement mainly creates the array in SAS for all the statements, starting with the array keyword, then using the array name, length, and some additional optional parameters.

Array length is the mandatory part and concept of the number of elements that must be enclosed with an open and closed set of brackets or other operators like open and closed parenthesis. Array length and Array type should be mandatory fields for the array statement with a specified set of elements to determine the number of elements specified for the array elements. The analytics will take more time for GUI advantage and applications like six sigma, designs and other quality controls, engineering, and scientific analysis. It is one platform-independent, so it runs on any operating system, either Linux, Windows and Solaris, mac os, etc. Elements length with the default set of characters for the numeric set of array elements stored with the data information at almost eight sets of characters. Statistical Analysis Software was used for data management software and other business intelligence.

The data step programmers will always use the arrays with their codes more frequently with fewer errors and prone jobs. Its revenue and mainly expense are the data set containing twice a year in the variables for revenues and expenses in the incoming month. As the number of data increases, more statements are required to calculate monthly income. We can get the result from the previous one, which will affect the prone type of jobs. The arrays can be mainly called for data increases and growth for more statements that can be required for net income in each month.

The basic syntax for the array is below:

Syntax:

ARRAY array-name[];

The above code syntax is the array statement which consists of the ARRAY keyword with pair of parentheses(), braces(), and square brackets[] for n number of variables or elements in the associated array.

SAS cannot be determined with the variable month until running the process in run time for the syntax.

Steps to Create SAS and Arrays

Given below are the steps to create SAS and Arrays:

1. Goto Studying SAS Demand for Academics(ODA) mainly provides students and professors free access to the SAS Studio via web-based browsers.

2. https://welcome.oda.sas.com/login.

SAS Array 1

3. Register the form using the Don’t have a SAS Profile option.

First Register the form

4. The Pop up is open, and select the Create Profile option; it navigates to another web page like the one below.

5. https://www.sas.com/profile/ui/#/create.

https://www.sas.com/profile/ui/#/create

6. Fill in all the required details and save it will create the SAS Profile for the specific user.

7. I have created a Profile already and signed it below.

8. https://welcome.oda.sas.com/home.

9. Goto Applications and select SAS Studio.

Goto Applications

10. It will navigate to other web pages like the one below.

11. https://odamid-apse1-2.oda.sas.com/SASStudio/mainlocale=en_US&zone=GMT%252B05%253A30&ticket=ST-77594-c3ENcyLUdJPdBC0tOV6C-cas.

SAS Array 5

12. Next, we need to use the codes like the below example and run them to get the output result like the screenshot below.

SAS Array 6

SAS Array 7

Examples of SAS Array

Different examples are mentioned below

Example #1

Code:

DATA firstarray;
INPUT in1 $ in2 $ in3 $ in4 $ in5 $;
ARRAY inps(5) $ in1-in5;
res = in1||'+'||in2 ||'+'||in3;
DATALINES;
Welcome To My Domain have a nice day
;
RUN;
PROC PRINT DATA = firstarray;
RUN;

Output:

SAS Array 8

  • In the above example, we declared the Input as the array format with string type.
  • Then we declared Array input with index range values.
  • We used res as the variable to perform the arithmetic, or other user operations concatenate operations.
  • Initially, we declare the firstarray as the variable to be started.
  • After execution, the DATALINES will be printed on the required array index tables.

Example #2

Code:

DATA second;
  INPUT X1 X2 X3 X4;
  ARRAY ar(4) X1-X4;
   ARRAY days(4) X1-X4;
out1 = SUM(OF ar(*));
out2 = MEAN(OF ar(*));
out3 = MIN(OF ar(*));
   DATALINES;
41 42 43 44
51 52 53 54
   IF 'Sunday' IN days THEN Leave = 'Yes';ELSE Leave = 'No';
DATALINES;
Sunday Monday Tuesday Wednesday
;
RUN;
PROC PRINT DATA = second;
RUN;

Output:

WORK.SECOND

  • We followed the same procedure as the previous example in the second example.
  • Here Additionally, performed the Arithmetic and Aggregate functions of the array elements with the sequence index ranges.
  • We started the SUM(), MEAN(), and MIN() operations for performing the DATALINES operations.
  • It will be printed on the console and stored as table datas.

Conclusion

Generally, when we work with a set or group of datas that are exactly similar to one another, it means the duplicated things that will be performed in the specific or common operations in the application. With significant time the datas will be reduced in the number of lines of codes to get the result with an additional task.

Recommended Articles

This is a guide to SAS Array. Here we discuss the introduction, Steps to create, and how to create and use a SAS array with examples. You may also have a look at the following articles to learn more –

  1. CSS Margin
  2. CSS Element Selector
  3. CSS Linear Gradient
  4. Justify Text in CSS
EVIEWS Course Bundle - 11 Courses in 1
22+ Hours of HD Videos
11 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
MYSQL Course Bundle - 18 Courses in 1 | 3 Mock Tests
93+ Hour of HD Videos
18 Courses
3 Mock Tests & Quizzes
Verifiable Certificate of Completion
Lifetime Access
4.5
CLOUD COMPUTING Course Bundle - 23 Courses in 1
96+ Hours of HD Videos
23 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
SPLUNK Course Bundle - 12 Courses in 1
55+ Hours of HD Videos
12 Courses
Verifiable Certificate of Completion
Lifetime Access
4.5
Primary Sidebar
Popular Course in this category
SAS PROGRAMMING Course Bundle - 18 Courses in 1 | 8 Mock Tests
 123+ Hours of HD Videos
18 Courses
8 Mock Tests & Quizzes
  Verifiable Certificate of Completion
  Lifetime Access
4.5
Price

View Course
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more