As support analysts in the SAS Technical Support division, we answer many phone calls from SAS customers. As members of the SAS Foundation team, we get questions that vary significantly in content from all of the areas that we support. We offer coding tips and suggestions as well as point customers to SAS Notes and documentation. A common question that we are frequently asked is how to collapse a data set with many observations for the same BY variable value into a data set that has one observation per BY variable value. Another way to phrase this question is: how do you reshape the data from “long to wide?”
Resources to Reshape Data
The following SAS Note illustrates how to use two TRANSPOSE procedure steps to collapse the observations for multiple BY variables:
Sample 44637: Double PROC TRANSPOSE method for reshaping your data set with multiple BY variables
If you prefer to use the DATA step rather than PROC TRANSPOSE, the following SAS Note provides a code sample that accomplishes the same purpose:
If the data set is “wide” and you’d like to expand each observation into multiple observations to make it a “long” data set, the following SAS Note is helpful:
Sample 24794: Expand single observations into multiple observations
Brief Overview of Some Support.sas.com Resources
Since we’ve been discussing SAS Notes from the support.sas.com site, here is a brief overview of how to use the site to find other helpful items for your future coding projects.
Documentation
- Go to support.sas.com
- On the left side of the page in the Knowledge Base section, select Documentation, Product Index A-Z, and then select your product of interest to access user guides and other documentation resources.
SAS Notes
- Go to support.sas.com
- On the left side of the page in the Knowledge Base section, select Samples & SAS Notes.
- From this page, you can type keywords in the Search box to get a list of relevant notes from both categories.
Note: If you’re interested in specific types of notes (for example, samples or problem notes), select the type of note from the choices given on the left side of the page underneath Samples & SAS Notes.
It was a pleasure to work with you in 2015 when you contacted us for assistance. We look forward to another great year in 2016.