Dear Statalist Users
My problem is probably a basic one for you to solve, but I hope you will take a little time to help me - I have used all day trying to solve what I believed would be really easy to do.
Below is a very simplified version of my dataset.
I would like STATA to find the maximum value of "LKF" and then return the values of "Frame" and "LKVarus" in the same row as the max value of LKF (e.g. the value of Frame that STATA should return should be 3 in my simplified dataset).
I am going to use these specific values of "Frame" and "LKVarus" in a later analysis, so I try to create local values for this later use.
Here is the simplified dataset (please note that both LKF and LKVarus contains a few missing values as this gave me some problems in my early attempts).
I have tried to solve it in several different ways, but my most promising try is probably this one:
When I run the code I get the following message:
0 If not found
r(111)
Can you help get the "local Frame_at_LFKMax" right or maybe suggest another way for me to solve this issue?
Thanks in advance
My problem is probably a basic one for you to solve, but I hope you will take a little time to help me - I have used all day trying to solve what I believed would be really easy to do.
Below is a very simplified version of my dataset.
I would like STATA to find the maximum value of "LKF" and then return the values of "Frame" and "LKVarus" in the same row as the max value of LKF (e.g. the value of Frame that STATA should return should be 3 in my simplified dataset).
I am going to use these specific values of "Frame" and "LKVarus" in a later analysis, so I try to create local values for this later use.
Here is the simplified dataset (please note that both LKF and LKVarus contains a few missing values as this gave me some problems in my early attempts).
Frame | LKF | LKVarus |
0 | 1 | 2 |
1 | 2 | 2 |
2 | 3 | 2 |
3 | 4 | 1 |
4 | . | . |
5 | . | . |
Code:
summarize LKF local LKFMax = r(max) local Frame_at_LFKMax Frame if LKF=`LFKMax' display `Frame_at_LFKMax'
0 If not found
r(111)
Can you help get the "local Frame_at_LFKMax" right or maybe suggest another way for me to solve this issue?
Thanks in advance
Comment