HI Folks, any chance there is an option I'm overlooking in xpose or sxpose here?
Mock version of my data:
The goal (variable for each of the words plus a variable for the firms):
Worked on a few possible solutions. The two best are below. Anyone able to help me figure out the final touches?
First attempt (lost track of the words):
Second attempt (lost track of firm name):
Mock version of my data:
Code:
clear all
input str40 words firm1 firm2 firm3
"cat" 28 0 0
"dog" 26 0 26
"hat" 21 0 14
"desk" 19 0 7
"car" 17 0 2
end
. list
+-------------------------------+
| words firm1 firm2 firm3 |
|-------------------------------|
1. | cat 28 0 0 |
2. | dog 26 0 26 |
3. | hat 21 0 14 |
4. | desk 19 0 7 |
5. | car 17 0 2 |
+-------------------------------+
Code:
+-----------------------------------------+
| cat dog hat desk car firmname |
|-----------------------------------------|
1. | 28 26 21 19 17 firm1 |
2. | 0 0 0 0 0 firm2 |
3. | 0 26 14 7 2 firm3 |
+-----------------------------------------+
First attempt (lost track of the words):
Code:
xpose, clear varname
list
+-----------------------------------+
| v1 v2 v3 v4 v5 _varname |
|-----------------------------------|
1. | . . . . . words |
2. | 28 26 21 19 17 firm1 |
3. | 0 0 0 0 0 firm2 |
4. | 0 26 14 7 2 firm3 |
+-----------------------------------+
Code:
sxpose, clear force firstnames destring
list
+------------------------------+
| cat dog hat desk car |
|------------------------------|
1. | 28 26 21 19 17 |
2. | 0 0 0 0 0 |
3. | 0 26 14 7 2 |
+------------------------------+

Comment