Returns a number from a SAS PD value. The first string contains the number, and the second string contains the W.D format.
real PD(string[, string])
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)
string
the second string is the SAS format, specified as W(idth).D(ecimal)
// 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