Dear All:
How can I change count data into Binary data?
Data:
data Thesis;
input ID success trial;
data lines;
1 2 4
2 3 6
3 1 3
; run;
Desired data binary data:
ID cluster_Id status
1 11 1
1 12 1
1 13 0
1 14 0
2 21 1
2 22 1
2 23 1
2 24 0
2 25 0
2 26 0
3 31 1
3 32 0
3 33 0
Thank you much!
Here's one way. Note that I'm changing your CLUSTER_ID values (101, 102, 103, instead of 11, 12, 13) because I think it's likely you will have 10+ trials for some IDs and that would cause a conflict between the CLUSTER_ID values:
data want;
set thesis;
cluster_id = 100 * id;
do j = 1 to trial;
cluster_id + 1;
if j <= success then status=1;
else status=0;
output;
end;
keep id cluster_id status;
run;
first of all, make sure that you need to do that. What do you intend to do with the new data set that you can't do with the original? you might save yourself some time
Here's one way. Note that I'm changing your CLUSTER_ID values (101, 102, 103, instead of 11, 12, 13) because I think it's likely you will have 10+ trials for some IDs and that would cause a conflict between the CLUSTER_ID values:
data want;
set thesis;
cluster_id = 100 * id;
do j = 1 to trial;
cluster_id + 1;
if j <= success then status=1;
else status=0;
output;
end;
keep id cluster_id status;
run;
Whether you're already using SAS Event Stream Processing or thinking about it, this is where you can connect with your peers, ask questions and find resources.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.