Hello, I am very very to Stata and trying to teach myself but I am stuck on this issue. I don't know the exact terminology so my apologies if I mixed up some of my words.

Essentially, I have a row for every hospital visit for each patient (could be anywhere from 1-100 rows). At it's most basic, each row has variables for patient ID, all outcomes (var1, var2, var3,...,var25), and the date of the hospital visit (as days from enrollment).

The outcomes are all coded and are string variables.

Code:
  
ID outcome1 outcome2 outcome3 outcome4 outcomeN date visit
001 X1 X2 X3 5 1
001 X4 X5 45 2
001 X1 X2 X5 X6 X7 104 3
001 X1 200 4
001 X6 302 5
001 X1 X2 333 6
002 X4 32 1
002 X7 100 2
002 X1 X2 121 3
My question is if there is a somewhat automated way to break down each row into a separate row for each outcome under one outcome variable, maintaining the ID, the outcome variable string, and the date associated.

So using the first row of the example above:

Code:
Starts as:
  
ID outcome1 outcome2 outcome3 outcome4 outcomeN date visit
001 X1 X2 X3 5 1
Convert to: 
ID outcome date visit
001 X1 5 1
001 X2 5 1
001 X3 5 1
I surely can long-code this, but as noted there are as many as 25 outcome variables for each now, and any number of visits for each patient, so I am hoping there is a loop or script that can automate this.

Apologies, for the long post, I hope this makes sense.