SAS Macros to Transpose Multiple Variables from Wide to Long and Long to Wide

The following SAS macros: are aimed at reshaping multiple variables in SAS. In SAS, the Data step and Procedure step can be used to transpose long format variables to wide format and vice versa but only few variables at a time.

Quite a few macros have been written to help with transposing several variables at a time but they are either difficult to use or voluminous.

In the current project, two SAS macros are written to transpose wide variables format to long variable formats when data are repeatedly measured on the same variables. The current macros are very simple and should be used with ease if the repeated variables follow a common pattern. After using the macros, the user may need to make minimum edits to remove unnecessary rows added.

Leave a Reply

Your email address will not be published. Required fields are marked *