noobpromotion.blogg.se

Stata mean by group
Stata mean by group












One other important thing to note: the sum() function that you mention, which works with -generate-, produces a running sum within by-groups. So whatever the correct name of the variable that holds the blood pressure measurements is belongs in there.Īlso, there really is no need to include (timeslots) in the by-prefix here: it doesn't do anything since the mean() function is invariant with respect to the order of the observations within the by-group. But I need the mean value not the sum for each timeslot!!!!!!Ĭode: by patientid (timeslots), sort: egen MEAN1 = mean(blood pressure value)will work, except that "blood pressure value" is not a valid Stata expression due to the embedded blanks. If I replace "mean" with "sum" in the above query it works fine - i get at value which is the sum of each group of patients.

stata mean by group

"by patientid (timeslots), sort: gen MEAN1 = mean(blood pressure value)" I have tried the following, but I'm getting a notice of "unknown function mean ()" How do I generate the blood pressure mean value to be used in the graph? I am looking for a functionality in the same category as the one calculating the "sum", which can be allocated to be a value in a new variable. A simple x-y graph with mean blood pressure as a function of time. Now I would like to show the mean blood pressure for all the patients within the same relative timeslot as a function of time - to see if the mean blood pressure has changed from before to after they experienced the drug. All patients now have comparable timeslots. the patients unique timestamps for an blood pressure observation were exchanged with 5 min timeslots relative to when they first experience the drug. All patients data has been allocated to small timeslots each of 5 minutes interval on both sides (before and after) the incidence (relative reference timepoint) i.e. first time the patient has experienced administration of a specific drug. I have chosen the incidence of a specifik event as a reference - i.e.

stata mean by group

I have data on blood pressure on thousand of people obtained at different timepoints during a year.














Stata mean by group