<?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 Identifying the earliest date for a composite variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-the-earliest-date-for-a-composite-variable/m-p/755785#M238563</link>
    <description>&lt;P&gt;I am a beginner SAS user and would really appreciate some help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an example of the dataset I have for several thousands of patients:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Patient_ID&lt;/TD&gt;&lt;TD&gt;HF&lt;/TD&gt;&lt;TD&gt;HF_date&lt;/TD&gt;&lt;TD&gt;MI&lt;/TD&gt;&lt;TD&gt;MI_date&lt;/TD&gt;&lt;TD&gt;Stroke&lt;/TD&gt;&lt;TD&gt;Stroke_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;31DEC2019&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;06AUG2005&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;HF=Heart Failure, MI=Myocardial Infarction&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on a survival analysis and will need to do it for a composite outcome called MACE (which will the 3 variables in my dataset: HF, MI and stroke).&lt;/P&gt;&lt;P&gt;I am trying to find the best way to create a MACE_date that reflects the earliest date if a patient has more than 2 outcomes. So for patient 1 above, I would want the MACE_date to be 06AUG2005 instead of 31DEC2019.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently have:&lt;/P&gt;&lt;P&gt;MACE=0;&lt;/P&gt;&lt;P&gt;if HF=1 then MACE=1;&lt;/P&gt;&lt;P&gt;if MI=1 then MACE=1;&lt;/P&gt;&lt;P&gt;if stroke=1 then MACE=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MACE_date=.;&lt;/P&gt;&lt;P&gt;if HF=1 then MACE_date=HF_date;&lt;/P&gt;&lt;P&gt;if MI=1 then MACE_date=MI_date;&lt;/P&gt;&lt;P&gt;if Stroke=1 then MACE_date=Stroke_date;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I code my SAS in a way where if a patient has multiple outcomes (HF and MI and stroke), that the MACE_date will reflect the earliest date? Is there an easy way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advance&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jul 2021 23:38:20 GMT</pubDate>
    <dc:creator>jennxxness</dc:creator>
    <dc:date>2021-07-21T23:38:20Z</dc:date>
    <item>
      <title>Identifying the earliest date for a composite variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-the-earliest-date-for-a-composite-variable/m-p/755785#M238563</link>
      <description>&lt;P&gt;I am a beginner SAS user and would really appreciate some help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is an example of the dataset I have for several thousands of patients:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Patient_ID&lt;/TD&gt;&lt;TD&gt;HF&lt;/TD&gt;&lt;TD&gt;HF_date&lt;/TD&gt;&lt;TD&gt;MI&lt;/TD&gt;&lt;TD&gt;MI_date&lt;/TD&gt;&lt;TD&gt;Stroke&lt;/TD&gt;&lt;TD&gt;Stroke_date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;31DEC2019&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;06AUG2005&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;HF=Heart Failure, MI=Myocardial Infarction&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on a survival analysis and will need to do it for a composite outcome called MACE (which will the 3 variables in my dataset: HF, MI and stroke).&lt;/P&gt;&lt;P&gt;I am trying to find the best way to create a MACE_date that reflects the earliest date if a patient has more than 2 outcomes. So for patient 1 above, I would want the MACE_date to be 06AUG2005 instead of 31DEC2019.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I currently have:&lt;/P&gt;&lt;P&gt;MACE=0;&lt;/P&gt;&lt;P&gt;if HF=1 then MACE=1;&lt;/P&gt;&lt;P&gt;if MI=1 then MACE=1;&lt;/P&gt;&lt;P&gt;if stroke=1 then MACE=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MACE_date=.;&lt;/P&gt;&lt;P&gt;if HF=1 then MACE_date=HF_date;&lt;/P&gt;&lt;P&gt;if MI=1 then MACE_date=MI_date;&lt;/P&gt;&lt;P&gt;if Stroke=1 then MACE_date=Stroke_date;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I code my SAS in a way where if a patient has multiple outcomes (HF and MI and stroke), that the MACE_date will reflect the earliest date? Is there an easy way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much in advance&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 23:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-the-earliest-date-for-a-composite-variable/m-p/755785#M238563</guid>
      <dc:creator>jennxxness</dc:creator>
      <dc:date>2021-07-21T23:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying the earliest date for a composite variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-the-earliest-date-for-a-composite-variable/m-p/755789#M238566</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MACE=0;
if max(HF, MI, STROKE) = 1 then MACE=1;


MACE_date=.;
if MACE =1 then MACE_DATE = min(HF_Date, MI_Date, STROKE_DATE);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use the MIN/MAX functions.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your first condition can be simplified to checking if the max of any of the variables (assuming they take only ., 0, 1) are 1 and you can simplify the last portion to take the minimum. Missing values are ignored.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/373359"&gt;@jennxxness&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am a beginner SAS user and would really appreciate some help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is an example of the dataset I have for several thousands of patients:&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Patient_ID&lt;/TD&gt;
&lt;TD&gt;HF&lt;/TD&gt;
&lt;TD&gt;HF_date&lt;/TD&gt;
&lt;TD&gt;MI&lt;/TD&gt;
&lt;TD&gt;MI_date&lt;/TD&gt;
&lt;TD&gt;Stroke&lt;/TD&gt;
&lt;TD&gt;Stroke_date&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;.&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;31DEC2019&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;06AUG2005&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;HF=Heart Failure, MI=Myocardial Infarction&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working on a survival analysis and will need to do it for a composite outcome called MACE (which will the 3 variables in my dataset: HF, MI and stroke).&lt;/P&gt;
&lt;P&gt;I am trying to find the best way to create a MACE_date that reflects the earliest date if a patient has more than 2 outcomes. So for patient 1 above, I would want the MACE_date to be 06AUG2005 instead of 31DEC2019.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I currently have:&lt;/P&gt;
&lt;P&gt;MACE=0;&lt;/P&gt;
&lt;P&gt;if HF=1 then MACE=1;&lt;/P&gt;
&lt;P&gt;if MI=1 then MACE=1;&lt;/P&gt;
&lt;P&gt;if stroke=1 then MACE=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MACE_date=.;&lt;/P&gt;
&lt;P&gt;if HF=1 then MACE_date=HF_date;&lt;/P&gt;
&lt;P&gt;if MI=1 then MACE_date=MI_date;&lt;/P&gt;
&lt;P&gt;if Stroke=1 then MACE_date=Stroke_date;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I code my SAS in a way where if a patient has multiple outcomes (HF and MI and stroke), that the MACE_date will reflect the earliest date? Is there an easy way to do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much in advance&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 23:46:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-the-earliest-date-for-a-composite-variable/m-p/755789#M238566</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-07-21T23:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying the earliest date for a composite variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-the-earliest-date-for-a-composite-variable/m-p/755790#M238567</link>
      <description>Thank you so much!</description>
      <pubDate>Wed, 21 Jul 2021 23:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-the-earliest-date-for-a-composite-variable/m-p/755790#M238567</guid>
      <dc:creator>jennxxness</dc:creator>
      <dc:date>2021-07-21T23:53:13Z</dc:date>
    </item>
  </channel>
</rss>

