If you'd like the SAS macro that does this both in SAS9 and in SAS Viya, I have written it for both.