Hi, i've been attempting to sort a large dataset which contains data collected from participants over time.
This includes identifying data (indexno) and entries over time. Entries are shown by the "count" variable and the dates of the entries are given by the variable "date1".
There are several binary variables and it is important whether these occur before or after the entry shown by the "newevent" variable.
For each of the participants identified by the indexno; if a variable occurs before, but not at the same time as the "newevent" variable, I'm trying to add this to the same entry as the "newevent" and delete the prior entries.
Examples of the datasets are given below which I hope will make this clearer:
Below is what I am aiming for:
Many thanks for your advice!
This includes identifying data (indexno) and entries over time. Entries are shown by the "count" variable and the dates of the entries are given by the variable "date1".
There are several binary variables and it is important whether these occur before or after the entry shown by the "newevent" variable.
For each of the participants identified by the indexno; if a variable occurs before, but not at the same time as the "newevent" variable, I'm trying to add this to the same entry as the "newevent" and delete the prior entries.
Examples of the datasets are given below which I hope will make this clearer:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float indexno long id float(count newevent date1 var1 var2 var3 var4) 256789 4 1 0 18447 1 1 0 1 256789 4 2 0 18773 0 1 0 1 256789 4 3 1 19726 0 0 0 1 256789 4 4 0 19799 0 0 1 0 256789 4 5 0 20777 0 0 1 1 256789 4 6 0 21383 0 0 1 0 347652 2 1 1 19084 0 0 0 0 347652 2 2 0 19701 0 0 0 0 347652 2 3 0 20768 0 0 0 0 347652 2 4 0 20830 0 0 0 1 347652 2 5 0 20894 0 0 0 1 347652 2 6 0 21189 0 0 0 1 347652 2 7 0 21455 0 0 0 0 347652 2 8 0 21883 0 0 0 0 347652 2 9 0 22277 0 0 0 0 456736 1 1 0 13808 0 1 0 1 456736 1 2 0 13889 0 1 0 1 456736 1 3 0 14280 0 1 0 1 456736 1 4 0 14722 0 1 0 0 456736 1 6 0 15215 0 1 0 0 456736 1 7 1 15663 0 1 0 0 456736 1 8 0 16061 0 1 0 0 456736 1 9 0 17550 0 1 0 0 156782 3 1 0 16576 0 0 0 1 156782 3 2 0 17705 1 0 0 1 156782 3 3 0 18101 1 0 0 1 156782 3 4 1 18479 1 0 0 0 156782 3 5 0 18825 0 0 0 0 end format %td date1 label values id id label def id 1 "83hf9390", modify label def id 2 "88829bb3", modify label def id 3 "8hgh838", modify label def id 4 "d348fjf3", modify
Below is what I am aiming for:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float indexno long id float(count newevent date1 var1 var2 var3 var4 var1a var2a var4a) 256789 4 3 1 19726 0 0 0 1 1 1 1 256789 4 4 0 19799 0 0 1 0 0 0 0 256789 4 5 0 20777 0 0 1 1 0 0 0 256789 4 6 0 21383 0 0 1 0 0 0 0 347652 2 1 1 19084 0 0 0 0 0 0 0 347652 2 2 0 19701 0 0 0 0 0 0 0 347652 2 3 0 20768 0 0 0 0 0 0 0 347652 2 4 0 20830 0 0 0 1 0 0 0 347652 2 5 0 20894 0 0 0 1 0 0 0 347652 2 6 0 21189 0 0 0 1 0 0 0 347652 2 7 0 21455 0 0 0 0 0 0 0 347652 2 8 0 21883 0 0 0 0 0 0 0 347652 2 9 0 22277 0 0 0 0 0 0 0 456736 1 7 1 15663 0 1 0 0 0 1 1 456736 1 8 0 16061 0 1 0 0 0 0 0 456736 1 9 0 17550 0 1 0 0 0 0 0 156782 3 4 1 18479 1 0 0 0 1 0 1 156782 3 5 0 18825 0 0 0 0 0 0 0 end format %td date1 label values id id label def id 1 "83hf9390", modify label def id 2 "88829bb3", modify label def id 3 "8hgh838", modify label def id 4 "d348fjf3", modify
Many thanks for your advice!
Comment