BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Lijuu
Obsidian | Level 7

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!

 

 

          

                     

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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;

View solution in original post

4 REPLIES 4
pau13rown
Lapis Lazuli | Level 10

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

Lijuu
Obsidian | Level 7
Because I want to account repeated trail that taken per subject using GEE logistic regression!

Thank You.
Astounding
PROC Star

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;

Lijuu
Obsidian | Level 7
Thank You! @Astounding!

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.

 

Multiple Linear Regression in SAS

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.

Discussion stats
  • 4 replies
  • 1859 views
  • 0 likes
  • 3 in conversation