Hi,
I need to create the respondent-driven sampling variables identifying recruits from two variables:
I need to add variables identifying caseID # 2 and #3 as being friend1 and friend2 of caseID #1, and caseID #5 and #6 as friend1 and friend 2 of caseID #3 (the other participants have missing values as they have not successfully recruited friends yet). For example:
/*encoding str variables*/
encode recruiterID, generate(recruiterID_num)
encode participantID, generate(participantID_num)
/*counting and storing in r(max) the number of recruits to determine the number of friend_code_* variables to create*/
bysort recruiterID : gen nrecruits = _n
su nrecruits, meanonly
/*creating the friend_code_* variables*/
foreach i of num 1/`r(max)' {
by participantID_num, sort: gen friend_code_`i' = .
}
I need help figuring out how to copy the appropriate value of participantID in the friend_code_* variables (as required by the rds_network command). I just can't find the solution...
Many thanks,
Martin
I need to create the respondent-driven sampling variables identifying recruits from two variables:
recruiterID
and participantID
. caseID | recruiterID |
participantID |
1 | project_id |
Bn9Le8tQJt7uPT |
2 | Bn9Le8tQJt7uPT |
VKERQF4fGz0LVY |
3 | Bn9Le8tQJt7uPT | s0kRms5ndafnnfh |
4 | VKERQF4fGz0LVY |
R1E1MiDgYy8mcV |
5 | s0kRms5ndafnnfh | f3kpXDlkxxgu7K |
6 | s0kRms5ndafnnfh |
yb960dHZgItYe4L |
I need to add variables identifying caseID # 2 and #3 as being friend1 and friend2 of caseID #1, and caseID #5 and #6 as friend1 and friend 2 of caseID #3 (the other participants have missing values as they have not successfully recruited friends yet). For example:
caseID | recruiterID |
participantID |
friend_code_1 | friend_code_2 |
1 | project_id |
Bn9Le8tQJt7uPT |
VKERQF4fGz0LVY |
s0kRms5ndafnnfh |
2 | Bn9Le8tQJt7uPT |
VKERQF4fGz0LVY |
R1E1MiDgYy8mcV |
|
3 | Bn9Le8tQJt7uPT | s0kRms5ndafnnfh | f3kpXDlkxxgu7K |
yb960dHZgItYe4L |
4 | VKERQF4fGz0LVY |
R1E1MiDgYy8mcV | ||
5 | s0kRms5ndafnnfh | f3kpXDlkxxgu7K | ||
6 | s0kRms5ndafnnfh |
yb960dHZgItYe4L |
Because the number of coupons differs according to some sociodemographic variables, I created
as much new friend_code_* variables as the maximum number of participants recruited by the same recruiter by the following syntax:/*encoding str variables*/
encode recruiterID, generate(recruiterID_num)
encode participantID, generate(participantID_num)
/*counting and storing in r(max) the number of recruits to determine the number of friend_code_* variables to create*/
bysort recruiterID : gen nrecruits = _n
su nrecruits, meanonly
/*creating the friend_code_* variables*/
foreach i of num 1/`r(max)' {
by participantID_num, sort: gen friend_code_`i' = .
}
I need help figuring out how to copy the appropriate value of participantID in the friend_code_* variables (as required by the rds_network command). I just can't find the solution...
Many thanks,
Martin