subroutine addattribute Get number of attributes Validate parameter lists Open dataset Foreach attribute Get attribute name and type Get comment (if required) Fetch appropriate value and write to dataset Close dataset end subroutine addattribute