I used a similar approach

https://communities.sas.com/t5/blogs/blogarticleprintpage/blog-id/saeblog-board/article-id/811/comment-id/828