PD Function

Experimental: This functionality is currently experimental and is not yet fully supported. Refer to Experimental Functions.

Returns a number from a SAS PD value. The first string contains the number, and the second string contains the W.D format.


Syntax

real PD(string[, string])

Required Arguments

real

is the numeric value returned by the function

string

the first string is the unformatted number; the second (optional) string is the SAS format, specified as W.D (width.decimal)

Optional Arguments

string

the second string is the SAS format, specified as W(idth).D(ecimal)

Example

// Declare a STRING variable to contain the packed decimal string

string pdstring

// Declare a REAL varialble to contain the real value of the packed decimal

real pdreal

// Declare a hidden INTEGER value to contain the packed decimal string

integer len

// Use FORMATPD function to create a packed decimal string

len = formatpd (30.56789, "8.2", pdstring);

// Format the packed decimal number into a real number of length 8 with 2 decimal places

pdreal = pd(pdstring, "8.2");

Results: This should return with a value of 30.57