<?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: Date equations in long form data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547992#M151910</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    merge have have(where=(visit_type=6) rename=(date=visit_type_6_date));
    by id;
    if date &amp;gt; visit_type_6_date then flag=1; else flag=0;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm not sure why you have not bolded the third record, it seems like under the rules you have explained, that one should get dropped as well.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2019 18:04:34 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-04-02T18:04:34Z</dc:date>
    <item>
      <title>Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547978#M151904</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a log form data set with a column for id, visit type and visit date. I want to create a new variable (0/1) indicating which visits have a date greater than the date for visit type='6' for each ID. So for example, in the simplified data below, I want to the drop the rows with bolded values because the dates for those visits come after the dates for visit type 6.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought I could do this with a simple combination of equation and IF/THEN statements, but I'm stumped. Suggestions?&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Visit Type&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD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&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;10-Oct&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;4&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;10-Dec&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 17:46:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547978#M151904</guid>
      <dc:creator>EpiNovice</dc:creator>
      <dc:date>2019-04-02T17:46:10Z</dc:date>
    </item>
    <item>
      <title>Re: Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547986#M151906</link>
      <description>&lt;P&gt;Are your dates true numeric SAS date values, formatted as shown? Or are they text as shown?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Will every ID value have one and only one visit type equal to 6? Could an ID have zero visit type records equal to 6? Could an ID have more than one visit type records equal to 6?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 17:58:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547986#M151906</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-02T17:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547987#M151907</link>
      <description>&lt;P&gt;The dates are formatted as yymmdd10&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 17:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547987#M151907</guid>
      <dc:creator>EpiNovice</dc:creator>
      <dc:date>2019-04-02T17:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547988#M151908</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Will every ID value have one and only one visit type equal to 6? Could an ID have zero visit type records equal to 6? Could an ID have more than one visit type records equal to 6?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 17:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547988#M151908</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-02T17:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547989#M151909</link>
      <description>Each ID only has a single visit type 6.</description>
      <pubDate>Tue, 02 Apr 2019 17:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547989#M151909</guid>
      <dc:creator>EpiNovice</dc:creator>
      <dc:date>2019-04-02T17:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547992#M151910</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    merge have have(where=(visit_type=6) rename=(date=visit_type_6_date));
    by id;
    if date &amp;gt; visit_type_6_date then flag=1; else flag=0;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm not sure why you have not bolded the third record, it seems like under the rules you have explained, that one should get dropped as well.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 18:04:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547992#M151910</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-02T18:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547993#M151911</link>
      <description>Why bother with dates?  Would this work;&lt;BR /&gt;&lt;BR /&gt;if VisitType &amp;gt; 6 then delete;</description>
      <pubDate>Tue, 02 Apr 2019 18:06:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547993#M151911</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-02T18:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547994#M151912</link>
      <description>It should have been bolded, thank you for pointing that out.</description>
      <pubDate>Tue, 02 Apr 2019 18:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/547994#M151912</guid>
      <dc:creator>EpiNovice</dc:creator>
      <dc:date>2019-04-02T18:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/548002#M151915</link>
      <description>Unfortunately no. The visit types are actually longer names, I just shortened them for simplicity.</description>
      <pubDate>Tue, 02 Apr 2019 18:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/548002#M151915</guid>
      <dc:creator>EpiNovice</dc:creator>
      <dc:date>2019-04-02T18:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/548031#M151928</link>
      <description>&lt;P&gt;For this solution to work properly, you need to reverse the order in the merge:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="token keyword"&gt;merge&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;where&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;visit_type&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;6&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;rename&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;date&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;visit_type_6_date&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;) have&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;id&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;date&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;gt;&lt;/SPAN&gt; visit_type_6_date &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; flag&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;else&lt;/SPAN&gt; flag&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;0&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise, the values on the first observation for each ID will be wrong.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 19:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/548031#M151928</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-04-02T19:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Date equations in long form data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/548040#M151934</link>
      <description>Thank you, I was wondering why there was something wrong with my new dataset.</description>
      <pubDate>Tue, 02 Apr 2019 20:29:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-equations-in-long-form-data/m-p/548040#M151934</guid>
      <dc:creator>EpiNovice</dc:creator>
      <dc:date>2019-04-02T20:29:47Z</dc:date>
    </item>
  </channel>
</rss>

