Nothing statistics here.
I have a table which is a similaroty matrix, and it looks like this,
a | b | c | |
---|---|---|---|
a | 1 | 0.8 | 0.7 |
b | 0.8 | 1 | 0.2 |
c | 0.7 | 0.2 | 1 |
I was hoping to do the following,
and let tables become either
Header 1 | a | a | b | b | c | c |
---|---|---|---|---|---|---|
a | 1 | a | 0.8 | b | 0.7 | c |
b | 0.8 | a | 1 | b | 0.2 | c |
c | 0.7 | a | 0.2 | b | 1 | c |
or the transpose of it, doesn't matter.
Header 1 | a | b |
---|---|---|
a | 1 | 0.8 |
a | a | a |
b | 0.8 | 1 |
b | b | b |
As long as I have the original table by row or by column,
seperated by one colume which is fullfilled by the "previous" column name or rowname.
Please let me know how to do this. Thank you very much.
Does the value for the text versions of a b and c ever change?
no, they shouldn't be changed at all. thanks.
If the data in the start table you presented is in a dataset foes this do what you need?
data want;
set have;
a_str = 'a';
b_str = 'b';
c_str = 'c';
label a_str = 'a'
b_str = 'b'
c_str = 'c'
;
run;
proc print data= want noobs label;
var a a_str b b_str c c_str;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.