Functions in SAS

The post is about Functions in SAS Software. Functions in SAS software are predefined routines that perform specific computations or transformations on data. They can be categorized into several types based on their functionality.

Introduction to Functions in SAS Software

SAS functions are predefined operations that perform specific computations on data, categorized by their purpose. Numeric functions handle mathematical calculations like rounding, summing, and logarithms. Character functions manipulate text data through substring extraction, case conversion, and concatenation. Date and time functions manage SAS date, time, and datetime values, enabling operations like extracting year/month/day or shifting dates by intervals.

In SAS, Statistical functions compute summary metrics such as mean, median, and standard deviation. Financial functions support business calculations like net present value and loan payments. Random number functions generate values from statistical distributions for simulations. Bitwise functions perform low-level binary operations. Array functions assist in managing array dimensions and bounds. Special functions include utilities for data type conversion and lagged value retrieval. Finally, file and I/O functions check file existence and manage input/output operations. Together, these functions streamline data processing, analysis, and reporting in SAS.

Here are the main types of functions in SAS Software:

Numeric Functions

Perform mathematical operations on numeric values. These functions are also called arithmetic functions.

FunctionShort Description
SUM()Sum of arguments
MEAN()Arithmetic mean
MIN() / MAX()Minimum/Maximum value
ROUND()Rounds a number
INT()Returns integer part of a number
ABS()Absolute value of the argument
SQRT()Square root
LOG() / LOG10()Returns the integer part of a number
Functions in SAS Software

Random Number Functions in SAS

These functions generate random numbers.

Random Number FunctionShort Description
RANUNI()Generates random numbers from Uniform distribution
RANNOR()Generates random numbers from a Normal distribution
RANBIN()Generates random numbers from a Binomial distribution

Financial Functions

The following are important and useful financial calculations.

Financial FunctionsShort Description
IRR()Internal rate of return
NPV()Returns Net Present Value
PMT()Loan payment calculation

Character Functions in SAS

Manipulate and analyze text (string) data. These functions can also be classified as character-handling functions.

Character FunctionsShort Description
SUBSTR()Extracts a substring from an argument
SCAN()Extracts a specified word from a string
TRIM() / STRIP()Removes trailing/leading blanks from character expression
UPCASE() / LOWCASE()Converts to uppercase/lowercase
CATX()Concatenates strings with a delimiter
INDEX()Finds the position of a
COMPRESS()Removes specific characters from a string

Statistical Functions

The following are some important functions for the computation of descriptive statistical measures.

Descriptive FunctionsShort Description
MEAN(), MEDIAN(), MODE()Returns measures of central tendencies, mean, median, and mode of the data
STD()Returns standard deviation
VAR()Returns the variance
N()Returns the count of non-missing values
NMISS()Returns the count of missing values

Date and Time Functions in SAS

These functions handle SAS date, time, and datetime values.

FunctionsShort Description
TODAY() / DATE()Returns the current date
MDY()Creates a date from month, day, year
YEAR() / MONTH() / DAY()Extracts year/month/day
INTCK()Computes intervals between dates
INTNX()Increments a date by intervals
DATEPART()Extracts the date from datetime
TIMEPART()Extracts time from datetime

Bitwise Functions

The following functions perform bit-level operations.

FunctionsShort Description
BAND()Bitwise AND
BOR()Bitwise OR
BNOT()Bitwise NOT

Array Functions

The following functions work with arrays.

FunctionsShort Description
DIM()Returns the size of an array
HBOUND() / LBOUND()Returns upper/ lower bounds of an array

Special Functions

Miscellaneous operations. These functions may be classified as conversion functions, too.

FunctionsShort Description
INPUT()Converts character to numeric/ date
PUT()Converts value to formatted text
LAG() / DIF()Access previous row values

File and I/O Functions

These functions handle file operations.

FunctionsShort Description
FILEEXIST()Checks if a file exists
FEXIST()Checks if a fileref exists

The SAS functions described above help us in data cleaning, transformation, and analysis in SAS programming/ Software.

First Year (Intermediate) Mathematics Quiz

Cluster Analysis Quiz 4

Test your knowledge with this Cluster Analysis Quiz featuring MCQs on k-means, k-medoids, k-means++, and k-median algorithms, along with key concepts like Manhattan distance, cosine similarity, CF tree split, and multi-class classification. Perfect for machine learning enthusiasts and data science learners to assess their understanding of unsupervised clustering techniques. Take the Cluster Analysis Quiz now and sharpen your skills!

Online Unsupervised machine learning technique cluster analysis quiz with answers

Online Unsupervised Machine Learning Cluster Analysis Quiz with Answers

1. If you need to choose between clustering and supervised learning for the following applications, which would you choose, clustering over supervised learning?

 
 
 
 

2. Considering the k-means algorithm, after the current iteration, we have three centroids (0, 1), (2, 1), and (-1, 2). Will points (0.5, 0.5) and (-0.5, 0) be assigned to the same cluster in the next iteration?

 
 

3. Which of the following statements is true?

 
 

4. Suppose X is a random variable with P(X=1)=0.5 and P(X=1)=0.5. In addition, we have another random variable Y=XX. What is the covariance between X and Y?

 
 
 

5. Given three vectors A, B, and C, suppose the cosine similarity between A and B is cos(A,B)=1.0, and the similarity between A and C is cos(A,C)=1.0. Can we determine the cosine similarity between B and C?

 
 

6. Is K-means guaranteed to find K clusters that lead to the global minimum of the SSE?

 
 

7. In the k-medoids algorithm, after computing the new center for each cluster, is the center always guaranteed to be one of the data points in that cluster?

 
 

8. Given the two-dimensional points (0, 3) and (4, 0), what is the Manhattan distance between those two points?

 
 
 
 

9. Which of the following statements is true?

 
 
 
 

10. Which of the following statements about k-medoids, k-median, and k-modes algorithms is correct?

 
 
 
 

11. Considering the k- median algorithm, if points (-1, 3), (-3, 1), and (-2, -1) are the only points that are assigned to the first cluster now, what is the new centroid for this cluster?

 
 
 
 

12. Is it possible that the SSE strictly increases after we recompute new centers in the k-means algorithm? Why?

 
 

13. When will a leaf entry in the CF tree split?

 
 

14. Which of the following statements, if any, is FALSE?

 
 
 
 

15. For k-means, will different initializations always lead to different clustering results?

 
 

16. When dealing with multi-class classification problems, which loss function should be used?

 
 
 
 

17. Which of the following statements is true?

 
 
 
 

18. Considering the k-means algorithm, if points (0, 3), (2, 1), and (-2, 2) are the only points that are assigned to the first cluster now, what is the new centroid for this cluster?

 
 
 
 

19. What are some common considerations and requirements for cluster analysis?

 
 
 
 

20. The k-means++ algorithm is designed for better initialization for k-means, which will take the farthest point from the currently selected centroids. Suppose k=2, and we have selected the first centroid as (0, 0). Among the following points (these are all the remaining points), which one should we take for the second centroid?

 
 
 
 

Online Cluster Analysis Quiz with Answers

  • Is K-means guaranteed to find K clusters that lead to the global minimum of the SSE?
  • When dealing with multi-class classification problems, which loss function should be used?
  • Is it possible that the SSE strictly increases after we recompute new centers in the k-means algorithm? Why?
  • For k-means, will different initializations always lead to different clustering results?
  • In the k-medoids algorithm, after computing the new center for each cluster, is the center always guaranteed to be one of the data points in that cluster?
  • Which of the following statements is true?
  • What are some common considerations and requirements for cluster analysis?
  • Which of the following statements is true?
  • If you need to choose between clustering and supervised learning for the following applications, which would you choose, clustering over supervised learning?
  • Which of the following statements is true?
  • Given the two-dimensional points (0, 3) and (4, 0), what is the Manhattan distance between those two points?
  • Given three vectors A, B, and C, suppose the cosine similarity between A and B is cos(A,B)=1.0, and the similarity between A and C is cos(A,C)=1.0. Can we determine the cosine similarity between B and C?
  • Suppose X is a random variable with P(X=1)=0.5 and P(X=1)=0.5. In addition, we have another random variable Y=XX. What is the covariance between X and Y?
  • Considering the k-means algorithm, after the current iteration, we have three centroids (0, 1), (2, 1), and (-1, 2). Will points (0.5, 0.5) and (-0.5, 0) be assigned to the same cluster in the next iteration?
  • Considering the k-means algorithm, if points (0, 3), (2, 1), and (-2, 2) are the only points that are assigned to the first cluster now, what is the new centroid for this cluster?
  • The k-means++ algorithm is designed for better initialization for k-means, which will take the farthest point from the currently selected centroids. Suppose k=2, and we have selected the first centroid as (0, 0). Among the following points (these are all the remaining points), which one should we take for the second centroid?
  • Considering the k- median algorithm, if points (-1, 3), (-3, 1), and (-2, -1) are the only points that are assigned to the first cluster now, what is the new centroid for this cluster?
  • Which of the following statements about k-medoids, k-median, and k-modes algorithms is correct?
  • Which of the following statements, if any, is FALSE?
  • When will a leaf entry in the CF tree split?

Try Deep Learning Quizzes

MS Excel Visualization MCQs 13

Test your Excel skills with this 20-question MCQ quiz on advanced data visualization! The MS Excel Visualization MCQs quiz covers key chart types like bubble charts, scatter plots, waterfall charts, hierarchy charts, population pyramids, and gauge charts—essential for effective data storytelling. Perfect for analysts, students, and professionals looking to master Excel’s powerful visualization tools. Take the MS Excel Visualization MCQs quiz now and see how well you know Excel charts!

Please go to MS Excel Visualization MCQs 13 to view the test

Online MS Excel Visualization MCQs with Answers

  • A bubble chart is like a scatter chart, with a third variable, and solves the problem of displaying three variables in a 2-dimensional chart.
  • What is the likely cause of the equal-sized bubbles in this 2-D bubble chart?
  • Outliers in scatter or bubble charts should always be removed, and no notes need to be made to supplement your chart.
  • If we were to add a third set of data, which included the same three variables used to plot the graph below, where the bubble size is the company size, Excel will usually add the new data set in a new colour.
  • In Excel, what is hierarchical data?
  • Before creating a hierarchy chart, the data must be arranged correctly. The first column must contain the main category.
  • Before you create a hierarchy chart, you need to organise your data by size.
  • If we re-created the chart below but did not include the main category (in the inner-most ring) and highlighted the main-sub-category as our first category instead, each country would be coloured differently.
  • What type of chart is the following?
  • The key difference between the Change Colours and Themes functionalities in Excel is that Themes includes suggestions for fonts as well.
  • A waterfall chart is ideal for showing the cumulative impact of a series of positive and negative components.
  • If a waterfall chart is composed of data from different categories, the order of the categories will impact the shape of the waterfall in the chart.
  • What is the following chart type?
  • How can we add a picture that is incorporated in the chart, the way it has been below?
  • When creating a Map chart, the countries (or states or regions) need to be in alphabetical order.
  • Why are some parts of the world shaded in grey in the Map chart below?
  • What is the most likely explanation for the Map chart appearing the way below?
  • To create a Population chart (population pyramid chart in demography) in Excel, we need to begin with a:
  • Consider the Gauge chart below. What would happen to this Combo chart if both chart elements were converted to a Doughnut?
  • How can we adjust the vertical axis in the chart below to appear on the extreme left of the chart?
MS Excel Visualization MCQs with Answers: Population chart ms excel quiz

Python Data Visualization Quiz