Skip to content

Instantly share code, notes, and snippets.

@benjamin-chan
Last active February 5, 2018 19:24
Show Gist options
  • Save benjamin-chan/bcfaad23dfc8ec735a01dcc4a1ccbfd4 to your computer and use it in GitHub Desktop.
Save benjamin-chan/bcfaad23dfc8ec735a01dcc4a1ccbfd4 to your computer and use it in GitHub Desktop.
clear
use "C:\Users\chanb\Box Sync\Share\BDPDropIn\Hinson\Simple_GCS.dta"
bysort recordid : egen meanGCS = mean(gcs)
bysort recordid : egen sdGCS = sd(gcs)
bysort recordid : egen countNonMissingGCS = count(gcs)
gen group1 = 0
replace group1 = 1 if sdGCS == 0 /* Assign to group1 if all GCS values are the same */
bysort recordid : egen minGCS = min(gcs) /* Calculate minimum GCS */
bysort recordid : gen gcsAtZero = gcs if hourofmeasurement == 0 /* Determine GCS at time 0 */
bysort recordid : egen group2 = max(minGCS == gcsAtZero) /* Assign to group2 if the minimum GCS is the GCS at time 0 */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment