<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Recoding continuous variables into an array of binary variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348600#M273443</link>
    <description>&lt;P&gt;Can you provide some sample data? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Apr 2017 06:20:12 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2017-04-10T06:20:12Z</dc:date>
    <item>
      <title>Recoding continuous variables into an array of binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348584#M273442</link>
      <description>&lt;P&gt;Hi, I am relatively new to SAS and stuck with a problem. For a certain type of time-to-event analysis, I need to create a new dataset from the one that I'm working with. In the original dataset, each study participant has one row of data. Assume we have a patient X who has been in our study for 5&amp;nbsp;years and has developed the event of interest in the fourth year of the study. I need to create an array for this person T1 through T5 that has the values [0 0 0 1 1], respectively. That is zeros for the three years without the event and ones for the years 4 and 5 that the event occurred. I need a way to figure out how to code this in SAS so that the system automatically does this procedure for some 60,000 patients in the dataset. Each patient has a different follow-up&amp;nbsp;time [1-24 years], may or may not have experienced the event [0 and 1] and may have the event of interest at any point in time during the follow-up. Can somebody please suggest how should I go about this problem? &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 03:35:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348584#M273442</guid>
      <dc:creator>Sina</dc:creator>
      <dc:date>2017-04-10T03:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding continuous variables into an array of binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348600#M273443</link>
      <description>&lt;P&gt;Can you provide some sample data? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 06:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348600#M273443</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-04-10T06:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding continuous variables into an array of binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348728#M273444</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a very simple dataset of what I have in mind:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data work.sample;
input ID followup event event_occur;
datalines;
1 8 0 .
2 15 1 9
3 3 0 .
4 8 0 .
5 12 1 5
run;&lt;/PRE&gt;&lt;P&gt;There are four variables. ID indicates patient's unique ID. followup is the total amount of time in years that the person has been in the study. The variable event indicates whether the event of interest has happened. Finally, for patients with event=1, there is a time called event_occured that shows at which year the event has occurred. For instance in patient&amp;nbsp;#2, she has been in the study for 15 years and then the event of interest occurred in year 9. The Binary array for her should be: 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1&lt;/P&gt;&lt;P&gt;On the other hand, patient #1 should have the following binary code of 8 zeros: 0 0 0 0 0 0 0 0&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 14:55:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348728#M273444</guid>
      <dc:creator>Sina</dc:creator>
      <dc:date>2017-04-10T14:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding continuous variables into an array of binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348735#M273445</link>
      <description>&lt;P&gt;And you want this in a dataset? If I understand you correctly, then in this case you want an output dataset with 15 additional variables (max(followup)) with 0/1?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 15:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348735#M273445</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-04-10T15:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding continuous variables into an array of binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348738#M273446</link>
      <description>Exactly! The new dataset would have additional variables equal to the maximum of the follow-up years.</description>
      <pubDate>Mon, 10 Apr 2017 15:12:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348738#M273446</guid>
      <dc:creator>Sina</dc:creator>
      <dc:date>2017-04-10T15:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding continuous variables into an array of binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348765#M273447</link>
      <description>&lt;P&gt;Like this? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.sample;
input ID followup event event_occur;
datalines;
1 8  0 .
2 15 1 9
3 3  0 .
4 8  0 .
5 12 1 5
;

proc sort data = sample;
   by descending followup;
run;

data _NULL_;
   set sample;
   if _N_=1 then call symput('cols',followup);
run;

%put Additional Columns: &amp;amp;cols;

proc sort data = sample;   
   by ID;
run;

data want;
   set sample;

   array period[&amp;amp;cols];
   
   i = 1;
   do until (i &amp;gt; followup);
      period[i] = 0;
      i + 1;
   end;

   if not missing(event_occur) then do j = event_occur to followup;
      period[j] = 1;
   end;

   drop i j;
run;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 15:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348765#M273447</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-04-10T15:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding continuous variables into an array of binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348797#M273448</link>
      <description>Oh my god! Yes! Exactly. Thank you so very much! Appreciate your help and time!</description>
      <pubDate>Mon, 10 Apr 2017 17:01:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348797#M273448</guid>
      <dc:creator>Sina</dc:creator>
      <dc:date>2017-04-10T17:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding continuous variables into an array of binary variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348800#M273449</link>
      <description>&lt;P&gt;Anytime, glad to help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 17:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-continuous-variables-into-an-array-of-binary-variables/m-p/348800#M273449</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-04-10T17:14:57Z</dc:date>
    </item>
  </channel>
</rss>

