How can the MIN function be used in SAS, and what are some examples of its usage? 2

How can the MIN function be used in SAS, and what are some examples of its usage?

The MIN function in SAS is used to find the minimum value in a given set of data. It can be applied to both numeric and character variables, allowing for versatile usage. For example, it can be used to determine the earliest date in a dataset, or the smallest amount in a list of expenses. By using the MIN function, users can easily extract the smallest value from a large dataset and incorporate it into their analysis or reporting. This function is particularly useful in data analysis and statistical modeling, as it allows for quick identification of the lowest value within a dataset. Additionally, the MIN function can be combined with other functions and procedures in SAS to perform more complex calculations and data manipulations. Overall, the MIN function is a valuable tool in SAS that simplifies the process of finding and utilizing the minimum value in a dataset.

Use the MIN Function in SAS (With Examples)


You can use the MIN function in SAS to find the smallest value in a list of values.

Here are the two most common ways to use this function:

Method 1: Find Minimum Value of One Column in Dataset

proc sql;
    select min(var1)
    from my_data;
quit;

Method 2: Find Minimum Value of One Column Grouped by Another Column in Dataset

proc sql;
    select var2, min(var1)
    from my_data;
    group by var2;
quit;

The following examples show how to use each method with the following dataset in SAS:

/*create dataset*/
data my_data;
    input team $ points;
    datalines;
A 12
A 14
A 19
A 23
A 20
A 11
A 14
B 20
B 21
B 29
B 14
B 19
B 17
B 30
;
run;

/*view dataset*/
proc printdata=my_data;

Note: The MIN function automatically ignores missing values when calculating the minimum value of a list.

Example 1: Find Minimum Value of One Column in Dataset

The following code shows how to calculate the minimum value in the points column of the dataset:

/*calculate minimum value of points*/
proc sql;
    select min(points)
    from my_data;
quit;

We can see that proc sql returns a table with a value of 11.

This represents the minimum value in the points column.

Example 2: Find Minimum Value of One Column Grouped by Another Column

/*calculate minimum value of points grouped by team*/
proc sql;
    select team, min(points)
    from my_data;
    group by team;
quit;

From the output we can see:

  • The minimum points value for team A is 11.
  • The minimum points value for team B is 14.

Note: You can find the complete documentation for the MIN function in SAS .

The following tutorials explain how to perform other common tasks in SAS:

Cite this article

stats writer (2024). How can the MIN function be used in SAS, and what are some examples of its usage?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-the-min-function-be-used-in-sas-and-what-are-some-examples-of-its-usage/

stats writer. "How can the MIN function be used in SAS, and what are some examples of its usage?." PSYCHOLOGICAL SCALES, 26 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-the-min-function-be-used-in-sas-and-what-are-some-examples-of-its-usage/.

stats writer. "How can the MIN function be used in SAS, and what are some examples of its usage?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-the-min-function-be-used-in-sas-and-what-are-some-examples-of-its-usage/.

stats writer (2024) 'How can the MIN function be used in SAS, and what are some examples of its usage?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-the-min-function-be-used-in-sas-and-what-are-some-examples-of-its-usage/.

[1] stats writer, "How can the MIN function be used in SAS, and what are some examples of its usage?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How can the MIN function be used in SAS, and what are some examples of its usage?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top