indexing records in epidatastat and retrieving values
Dear Sir, I am trying to retrieve value of variables based on other variables.
Example: a dataset with 3 observations: # region_code ill 1 21 4 2 30 10 3 40 6
i have tried the following:
sort region_code gen i s =_n @ill[1]
but i am getting the result of the last observation and not the first.
I will be thankful if you advise on how to retrieve the value of a variable based on record indexing. Sincerely Nada
To print the value of ill for the first sorted record, do this:
?ill[1]
@ only gets the current value of the variable, which will always be the first value of a field, but then analysis is somewhat confused by the [1]. @ is normally used with global variables
in your example @ill[1] *should* produce 4[1]
at least it does in my test.
Jamie
On Apr 14, 2017, at 18:02, EpiData development and support epidata-list@lists.umanitoba.ca wrote:
I am trying to retrieve value of variables based on other variables.
Example: a dataset with 3 observations: # region_code ill 1 21 4 2 30 10 3 40 6
i have tried the following:
sort region_code gen i s =_n @ill[1]
but i am getting the result of the last observation and not the first.
I will be thankful if you advise on how to retrieve the value of a variable based on record indexing.
participants (1)
-
EpiData development and support