Reputation: 35
I am trying to reformat a data set in SAS that I am outputting as a csv. It is currently in the format:
Type, Name, data1, data2, data3…
Dog, retriever, 20, 40, 60…
Dog, corgi, 10, 30, 50…
Cat, Persian, 15, 25, 35…
Cat, stray, 1, 2, 3…
And I am trying to get it in the format:
Dog, retriever, data1, 20
Dog, retriever, data2, 40
Dog, retriever, data3, 60
Dog, Corgi, data1, 10
Dog, corgi, data2, 30
Dog, corgi, data3, 50
Cat, Persian, data1, 15
Cat, Persian, data2, 25
Cat, Persian, data3, 35
Cat, Siamese, data1, 1
Cat, Siamese, data2, 2
Cat, Siamese, data3, 3
Do you know the best way to go about this in SAS?
Thanks
Upvotes: 0
Views: 71
Reputation: 4006
with proc transpose, something like this :
PROC TRANSPOSE DATA = ...
OUT=...
NAME=ValueSource
LABEL=ValueDescription
;
BY type name;
ID <a column with hte same value for all your observations>;
VAR data1 data2 data3;
RUN;
Upvotes: 1