• No products in the cart.

SAS Programming Functions

Play Video

SAS provides a wide range of built-in functions that can be used for various data processing and analysis tasks. Some of the commonly used SAS functions include:

1. Numeric Functions: These functions operate on numeric data and perform arithmetic or mathematical operations, such as SUM, MEAN, MIN, MAX, and ROUND.
2. Character Functions: These functions operate on character data and manipulate strings or perform text-related operations, such as LENGTH, TRIM, SUBSTR, and SCAN.
3. Date and Time Functions: These functions operate on SAS date and time values and perform various date-related calculations and formatting operations, such as INTCK, INTNX, and DATEPART.
4. Statistical Functions: These functions perform statistical calculations on data sets, such as CORR, COV, TTEST, ANOVA, and REG.
5. Random Number Functions: These functions generate random numbers according to various probability distributions, such as UNIFORM, NORMAL, and POISSON.
6. Macro Functions: These functions are used in SAS macros to perform various macro-related operations, such as %SYMGET, %STR, and %EVAL.

These functions can be used in SAS programs to perform various data processing and analysis tasks. For example, the following code uses the SUM function to calculate the total value of a numeric variable called SALES:

data mydata;

   set sales;

   total_sales = sum(sales);

run;

This code reads data from a data set called SALES, calculates the total sales using the SUM function, and writes the output to a new data set called MYDATA.

Play Video

 

What are the character function?

Character functions are built-in functions in SAS that operate on character strings. They can be used to manipulate character data, perform text-related operations, and transform strings in various ways. Some of the commonly used character functions in SAS include:

1. LENGTH: returns the length of a character string.
2. TRIM: removes leading and trailing blanks from a character string.
3. SUBSTR: extracts a substring from a character string.
4. SCAN: extracts a specific word from a character string.
5. COMPRESS: removes all occurrences of a specified set of characters from a character string.
6. UPCASE: converts all characters in a character string to uppercase.
7. LOWCASE: converts all characters in a character string to lowercase.
8. INDEX: finds the position of a specified substring within a character string.
9. CAT: concatenates two or more character strings.
10. STRIP: removes leading and trailing blanks, but leaves embedded blanks intact.

These character functions can be used in SAS programs to manipulate and transform character strings in various ways. For example, the following code uses the TRIM and COMPRESS functions to remove leading and trailing blanks and all occurrences of commas from a character variable called NAME:

data mydata;

   set names;

   cleaned_name = compress(trim(name), ‘,’);

run;

This code reads data from a data set called NAMES, removes leading and trailing blanks and all commas from the NAME variable using the TRIM and COMPRESS functions, and writes the output to a new variable called CLEANED_NAME in a new data set called MYDATA.

16/03/2023
Template Design © Bodhan soft technologies PVT.LTD. All rights reserved. <meta name="facebook-domain-verification" content="cg6nsg7wc0h385jtk0v0gswpb924ti" />

Connect with :




Chat with Us
1
We are Online
Hello ,
How we can help you ?