SAS Functions

15 Most Used SAS Functions to Spark In Data World

SAS functions are fundamental building blocks within the SAS programming language, offering a diverse range of tools for data manipulation, statistical analysis, and reporting.

These functions serve to streamline data processing workflows, enabling users to perform complex calculations, transformations, and aggregations with ease. From converting data types and manipulating strings to calculating summary statistics and generating descriptive reports, SAS functions provide versatile solutions to address a wide array of analytical needs. With their comprehensive functionality and intuitive syntax, SAS functions empower analysts to derive valuable insights from data, make informed decisions, and drive business success.

CHAR(): Converts numeric values to character values.

char_variable = char(numeric_variable);

 

INPUT(): Converts character values to numeric values.

numeric_variable = input(char_variable, informat.);

 

SUBSTR(): Extracts a substring from a character variable.

substring = substr(string_variable, starting_position, length);

 

TRIM(): Removes leading and trailing blanks from a character variable.

trimmed_variable = trim(original_variable);

 

UPCASE(): Converts characters to uppercase.

uppercase_variable = upcase(original_variable);

 

LOWCASE(): Converts characters to lowercase.

lowercase_variable = lowcase(original_variable);

 

CAT(): Concatenates character values.

concatenated_variable = cat(string1, string2, ...);

 

COUNT(): Counts the number of non-missing arguments.

count = count(arg1, arg2, ...);

 

MEAN(): Calculates the mean (average) of numeric values.

average = mean(var1, var2, ...);

 

SUM(): Calculates the sum of numeric values.

total = sum(var1, var2, ...);

 

N(): Counts the number of non-missing values.

count_nonmissing = n(var1, var2, ...);
SQRT(): Calculates the square root of a numeric value.
square_root = sqrt(number);

 

MAX(): Returns the maximum value among numeric arguments.

maximum_value = max(var1, var2, ...);

 

MIN(): Returns the minimum value among numeric arguments.

minimum_value = min(var1, var2, ...);

 

ROUND(): Rounds numeric values to a specified number of decimal places.

rounded_value = round(number, decimal_places);

 

Most Used SAS Functions To Analyze The Data

Below is the dataset named sales_data with variables Region, Sales_Rep, and Sales_Amount. Each observation represents the sales amount for a particular sales representative in a specific region.

/* Sample sales data */

data sales_data;

input Region $ Sales_Rep $ Sales_Amount;

datalines;

East Rep1 1000

East Rep2 1500

East Rep3 1200

West Rep4 800

West Rep5 1100

West Rep6 900

North Rep7 1300

North Rep8 950

North Rep9 1150

South Rep10 1400

South Rep11 1250

South Rep12 1050

Central Rep13 900

Central Rep14 800

Central Rep15 950

;

run;

/* Calculate total sales amount by region */

proc means data=sales_data noprint;

by Region;

var Sales_Amount;

output out=region_sales_sum sum=Total_Sales_Amount;

run;

/* Print total sales amount by region */

proc print data=region_sales_sum;

title ‘Total Sales Amount by Region’;

run;

/* Calculate average sales amount by region */

proc means data=sales_data noprint;

by Region;

var Sales_Amount;

output out=region_sales_avg mean=Average_Sales_Amount;

run;

/* Print average sales amount by region */

proc print data=region_sales_avg;

title ‘Average Sales Amount by Region’;

run;

/* Find the maximum sales amount by region */

proc summary data=sales_data nway;

by Region;

var Sales_Amount;

output out=max_sales_max(drop=_TYPE_ _FREQ_) max(Sales_Amount)=Max_Sales_Amount;

run;

/* Print maximum sales amount by region */

proc print data=max_sales_max;

title ‘Maximum Sales Amount by Region’;

run;

This analysis provides valuable insights into the sales performance across different regions and highlights both strengths and areas for potential improvement. By leveraging these insights, businesses can make informed decisions to optimize their sales strategies and maximize overall performance. Additionally, further exploration, such as examining factors influencing sales performance and implementing targeted interventions, can enhance overall sales effectiveness and drive business growth.

SAS functions

Regional Sales Performance

The total sales amount varies across regions, with the highest total sales observed in the East and South regions, each totaling $3,700. The Central region had the lowest total sales amount of $2,650.

Average Sales Performance

When considering the average sales amount per region, the East and South regions also lead with an average sales amount of approximately $1,233.33 each. The Central region follows closely with an average sales amount of $883.33. This indicates a relatively consistent performance across regions.

Individual Sales Performance

Analyzing the maximum sales amount achieved by sales representatives in each region highlights the top-performing representatives. For instance, in the East region, Rep2 achieved the highest sales amount of $1,500, contributing to the region’s overall strong performance.

Regional Disparities

While some regions, such as the East and South, exhibit higher sales amounts and averages, others, like the West and Central, show comparatively lower figures. Understanding these disparities can help in identifying areas for improvement and allocating resources effectively.

Conclusion

Overall, the breadth and versatility of SAS functions empower users to perform a wide range of data manipulation and analysis tasks, ultimately supporting informed decision-making processes and driving business success. By leveraging the capabilities of SAS functions effectively, analysts can extract meaningful insights from data, uncover patterns and trends, and derive actionable recommendations to address business challenges and opportunities.

 

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *