Hello,
I am working with a dataset with the names of 20 different medications taken by more than 1,000 patients. I need to know the list of all the medications distributed in 20 string variables.
For example:
I have checked previous forums on how to compute the number of different observations but unfortunately have not succeeded.
http://www.stata.com/support/faqs/da...-observations/
In particular, I have tried with the following:
by medication1 medication2, sort: gen nvals= _n ==1
count if nvals
replace nvals=sum(nvals)
replace nvals= nvals[_N]
Any help would be greatly appreciated.
Kind regards,
Alejandra
I am working with a dataset with the names of 20 different medications taken by more than 1,000 patients. I need to know the list of all the medications distributed in 20 string variables.
For example:
Person | Medication1 | Medication2 | Medication3 | Medication4 | Medication5... |
id1 | a | b | c | ||
id2 | b | d | e | ||
id3 | c | a | f | g | h |
Result: List of unique values | |
a | |
b | |
c | |
d | |
e | |
f | |
g | |
h |
http://www.stata.com/support/faqs/da...-observations/
In particular, I have tried with the following:
by medication1 medication2, sort: gen nvals= _n ==1
count if nvals
replace nvals=sum(nvals)
replace nvals= nvals[_N]
Any help would be greatly appreciated.
Kind regards,
Alejandra
Comment