Sentry Page Protection
Data Manipulation [14-18]
Reverse Transpose
You can also reverse transpose a data set using Proc Transpose.
The FOOD data set contains the price for the coffee, muffin, and cookies from McDonald's.
The price for each item is listed in 3 individual columns.
Let's take a look at how you can reverse transpose the data set and combine the 3 columns into one.
Example
Proc Transpose Data=Food Out=rt_Food;
Var Coffee Muffin Cookies;
Run;
VAR statement
The VAR statement lists the variables to be reverse transposed.
In our example, the variables listed there are Coffee, Muffin, and Cookies.
The prices for all 3 items are now listed under the COL1 variable!
NO ID statement
When performing reverse transpose, do NOT include the ID statement.
The ID statement is only needed when performing the standard transpose.
Exercise
Copy and run the T_Q2 data set from the yellow box below:
Copy and run the T_Q2 data set from the yellow box below:
The T_Q2 data set contains the transposed data set from Q2.
Perform a reverse transpose on T_Q2 and combine the profit from April, May, and June back into one column.
Create any data set or variable if needed.
Need some help?
HINT:
A BY statement will be needed.
SOLUTION:
Proc Transpose Data=t_q2 Out=rt_q2;
Var April May June;
By Store;
Run;
Fill out my online form.