# HBOUND Function

## HBOUND Function

Returns the upper bound of an array

Category: Array

#### Syntax

HBOUND < n >( array- name )

HBOUND ( array-name , bound-n )

#### Arguments

n

• specifies the dimension for which you want to know the upper bound. If no n value is specified, the HBOUND function returns the upper bound of the first dimension of the array.

array-name

• specifies the name of an array defined previously in the same DATA step.

bound-n

• specifies the dimension for which you want to know the upper bound. Use bound-n only if n is not specified.

#### Details

The HBOUND function returns the upper bound of a one-dimensional array or the upper bound of a specified dimension of a multidimensional array. Use HBOUND in array processing to avoid changing the upper bound of an iterative DO group each time you change the bounds of the array. HBOUND and LBOUND can be used together to return the values of the upper and lower bounds of an array dimension.

#### Comparisons

• HBOUND returns the literal value of the upper bound of an array dimension.

• DIM always returns a total count of the number of elements in an array dimension.

Note: This distinction is important when the lower bound of an array dimension has a value other than 1 and the upper bound has a value other than the total number of elements in the array dimension.

#### Example 1: One-dimensional Array

In this example, HBOUND returns the upper bound of the dimension, a value of 5. Therefore, SAS repeats the statements in the DO loop five times.

```array big{5} weight sex height state city;
do i=1 to hbound(big5);

more SAS statements

;
end;
```

#### Example 2: Multidimensional Array

This example shows two ways of specifying the HBOUND function for multidimensional arrays. Both methods return the same value for HBOUND, as shown in the table that follows the SAS code example.

```array mult{2:6,4:13,2} mult1-mult100;
```

Syntax

Alternative Syntax

Value

HBOUND(MULT)

HBOUND(MULT,1)

6

HBOUND2(MULT)

HBOUND(MULT,2)

13

HBOUND3(MULT)

HBOUND(MULT,3)

2

Functions:

• 'DIM Function' on page 499

• 'LBOUND Function' on page 624

Statements:

• 'ARRAY Statement' on page 1100

• 'Array Reference Statement' on page 1105

'Array Processing' in SAS Language Reference: Concepts

## HMS Function

Returns a SAS time value from hour , minute, and second values

Category: Date and Time

#### Syntax

HMS ( hour,minute,second )

hour

• is numeric.

minute

• is numeric.

second

• is numeric.

#### Details

The HMS function returns a positive numeric value that represents a SAS time value.

#### Examples

The following SAS statements produce these results:

SAS Statements

Results

```
hrid=hms(12,45,10);

put hrid

/ hrid time.;

```

```
45910

2:45:10

```

Functions:

• 'DHMS Function' on page 496

• 'HOUR Function' on page 579

• 'MINUTE Function' on page 647

• 'SECOND Function' on page 819

## HOUR Function

Returns the hour from a SAS time or datetime value

Category: Date and Time

#### Syntax

HOUR (< time datetime >)

#### Arguments

time

• specifies a SAS expression that represents a SAS time value.

datetime

• specifies a SAS expression that represents a SAS datetime value.

#### Details

The HOUR function returns a numeric value that represents the hour from a SAS time or datetime value. Numeric values can range from 0 through 23. HOUR always returns a positive number.

#### Examples

The following SAS statements produce these results:

SAS Statements

Results

```
now='1:30't;

h=hour(now);

put h;

```

```
1

```