Hello.
I'd like to ask for help.
I want to make goal, goal_pre, goal_post using by id and target.

To create a goal
in target, if "the below value" bigger than "the above value", it has 1.

To create a goal_pre
The value of goal goes up one by one.

To create a goal_post
The value of goal goes down one by one.

What should I do?
Thank!

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str6 id float(target goal_pre goal goal_post)
"A00011" 0 1 . .
"A00011" 1 . 1 .
"A00011" 1 1 . 1
"A00011" 2 . 1 .
"A00011" 2 1 . 1
"A00011" 3 . 1 .
"A00011" 3 . . 1
"A00011" 2 . . .
"A00011" 2 1 . .
"A00011" 3 . 1 .
"A00560" 1 . . .
"A00560" 1 1 . .
"A00560" 2 . 1 .
"A00560" 2 1 . 1
"A00560" 3 . 1 .
"A00560" 2 . . 1
"A00560" 1 1 . .
"A00560" 3 1 1 .
"A00560" 4 . 1 1
end