'How to transpose EG5.1
I have a data set of approximately this format:
Table format :
| ID | 2012 | 2013 | 2014 |
|---|---|---|---|
| A | 1 | 3 | |
| B | 2 | 4 |
And I want to transpose it to this format:
Table format :
| ID | Source | Value |
|---|---|---|
| A | 2012 | 1 |
| A | 2013 | 3 |
| B | 2012 | 2 |
| B | 2014 | 4 |
Using the Transpose task. I'm working in EG 5.1 and I've got a massive mental block on how to do this. Most of the guides are for doing this the opposite way around. Thanks so much in advance for any advice.
Solution 1:[1]
Use proc transpose instead. Create a new SAS program and run the following code:
proc transpose data = have
out = want(rename = (COL1 = Value)
where = (NOT missing(Value) )
)
name = Source;
by id;
var _NUMERIC_;
run;
Output:
ID Source Value
A 2012 1
A 2013 3
B 2012 2
B 2014 4
In Enterprise Guide, this is the Stack Columns task:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Stu Sztukowski |

