<?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: How to choose first character observation based on time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-first-character-observation-based-on-time/m-p/769945#M244198</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by ID;

retain first_found;
flag = 0;
if first.id then first_found=0;

if action = 'Test A' and first_found = 0 then do;
flag=1;
first_found=1;
end;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use another flag that is retained that checks if the first record was ever found.&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/397436"&gt;@msyteriouspages&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi there! I’m trying to create indicator values using two variables. I would like to get the first observation (of interest) according to the first time that observation occurs. For example, this is the dataset I have:&lt;BR /&gt;&lt;BR /&gt;ID Action DateTime&lt;BR /&gt;1 Started 01AUG2021:15:39:01.000&lt;BR /&gt;1 Test A 01AUG2021:15:41:01.000&lt;BR /&gt;1 Check 01AUG2021:16:32:01.000&lt;BR /&gt;1 Test A 01AUG2021:16:39:01.000&lt;BR /&gt;1 Test B 01AUG2021:17:55:01.000&lt;BR /&gt;&lt;BR /&gt;What I want:&lt;BR /&gt;&lt;BR /&gt;I want to create an indicator that records the first time Test A happens&lt;BR /&gt;&lt;BR /&gt;ID Action DateTime Test_A&lt;BR /&gt;1 Started 01AUG2021:15:39:01.000 0&lt;BR /&gt;1 Test A 01AUG2021:15:41:01.000 1&lt;BR /&gt;1 Check 01AUG2021:16:32:01.000 0&lt;BR /&gt;1 Test A 01AUG2021:16:39:01.000 0&lt;BR /&gt;1 Test B 01AUG2021:17:55:01.000 0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I tried multiple things, I tried to create a condition using minimum date &amp;amp;amp; also by the first occurrence but nothing worked. I’d greatly appreciate any help. Thank you&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Sep 2021 15:18:55 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-09-23T15:18:55Z</dc:date>
    <item>
      <title>How to choose first character observation based on time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-first-character-observation-based-on-time/m-p/769942#M244197</link>
      <description>Hi there! I’m trying to create indicator values using two variables. I would like to get the first observation (of interest) according to the first time that observation occurs. For example, this is the dataset I have:&lt;BR /&gt;&lt;BR /&gt;ID Action DateTime&lt;BR /&gt;1 Started 01AUG2021:15:39:01.000&lt;BR /&gt;1 Test A 01AUG2021:15:41:01.000&lt;BR /&gt;1 Check 01AUG2021:16:32:01.000&lt;BR /&gt;1 Test A 01AUG2021:16:39:01.000&lt;BR /&gt;1 Test B 01AUG2021:17:55:01.000&lt;BR /&gt;&lt;BR /&gt;What I want:&lt;BR /&gt;&lt;BR /&gt;I want to create an indicator that records the first time Test A happens&lt;BR /&gt;&lt;BR /&gt;ID Action DateTime Test_A&lt;BR /&gt;1 Started 01AUG2021:15:39:01.000 0&lt;BR /&gt;1 Test A 01AUG2021:15:41:01.000 1&lt;BR /&gt;1 Check 01AUG2021:16:32:01.000 0&lt;BR /&gt;1 Test A 01AUG2021:16:39:01.000 0&lt;BR /&gt;1 Test B 01AUG2021:17:55:01.000 0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I tried multiple things, I tried to create a condition using minimum date &amp;amp;amp; also by the first occurrence but nothing worked. I’d greatly appreciate any help. Thank you</description>
      <pubDate>Thu, 23 Sep 2021 15:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-first-character-observation-based-on-time/m-p/769942#M244197</guid>
      <dc:creator>msyteriouspages</dc:creator>
      <dc:date>2021-09-23T15:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to choose first character observation based on time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-choose-first-character-observation-based-on-time/m-p/769945#M244198</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by ID;

retain first_found;
flag = 0;
if first.id then first_found=0;

if action = 'Test A' and first_found = 0 then do;
flag=1;
first_found=1;
end;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use another flag that is retained that checks if the first record was ever found.&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/397436"&gt;@msyteriouspages&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi there! I’m trying to create indicator values using two variables. I would like to get the first observation (of interest) according to the first time that observation occurs. For example, this is the dataset I have:&lt;BR /&gt;&lt;BR /&gt;ID Action DateTime&lt;BR /&gt;1 Started 01AUG2021:15:39:01.000&lt;BR /&gt;1 Test A 01AUG2021:15:41:01.000&lt;BR /&gt;1 Check 01AUG2021:16:32:01.000&lt;BR /&gt;1 Test A 01AUG2021:16:39:01.000&lt;BR /&gt;1 Test B 01AUG2021:17:55:01.000&lt;BR /&gt;&lt;BR /&gt;What I want:&lt;BR /&gt;&lt;BR /&gt;I want to create an indicator that records the first time Test A happens&lt;BR /&gt;&lt;BR /&gt;ID Action DateTime Test_A&lt;BR /&gt;1 Started 01AUG2021:15:39:01.000 0&lt;BR /&gt;1 Test A 01AUG2021:15:41:01.000 1&lt;BR /&gt;1 Check 01AUG2021:16:32:01.000 0&lt;BR /&gt;1 Test A 01AUG2021:16:39:01.000 0&lt;BR /&gt;1 Test B 01AUG2021:17:55:01.000 0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I tried multiple things, I tried to create a condition using minimum date &amp;amp;amp; also by the first occurrence but nothing worked. I’d greatly appreciate any help. Thank you&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Sep 2021 15:18:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-choose-first-character-observation-based-on-time/m-p/769945#M244198</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-23T15:18:55Z</dc:date>
    </item>
  </channel>
</rss>

