<?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: Identifying onset in longitudinal data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504431#M134987</link>
    <description>&lt;P&gt;data WORK.CLASS;&lt;BR /&gt;infile datalines truncover;&lt;BR /&gt;input Name:$8.&amp;nbsp;disease datetime;&lt;BR /&gt;informat datetime datetime20.;&lt;BR /&gt;format datetime datetime20.;&lt;BR /&gt;datalines;&lt;BR /&gt;Alfred 0 04MAR14:23:55:00&lt;BR /&gt;Alfred 0 04MAR14:23:56:00&lt;BR /&gt;Alfred 1 04MAR14:23:57:00&lt;BR /&gt;Alfred 1 04MAR14:23:58:00&lt;BR /&gt;Alfred 1 04MAR14:23:59:00&lt;BR /&gt;Alfred 1 04MAR14:00:00:00&lt;BR /&gt;Alfred 1 04MAR14:01:01:00&lt;BR /&gt;Alfred 1 04MAR14:01:02:00&lt;BR /&gt;Alfred 1 04MAR14:01:03:00&lt;BR /&gt;Alfred 1 04MAR14:01:04:00&lt;/P&gt;&lt;P&gt;mary 0 04MAR14:23:55:00&lt;BR /&gt;mary 0 04MAR14:23:56:00&lt;BR /&gt;mary 0 04MAR14:23:57:00&lt;BR /&gt;mary 0 04MAR14:23:58:00&lt;BR /&gt;mary 0 04MAR14:23:59:00&lt;BR /&gt;mary 1 04MAR14:00:00:00&lt;BR /&gt;mary 1 04MAR14:01:01:00&lt;BR /&gt;mary 1 04MAR14:01:02:00&lt;BR /&gt;mary 1 04MAR14:01:03:00&lt;BR /&gt;mary 1 04MAR14:01:04:00&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like a variable that =1 just on the FIRST time disease=1. For example, the variable would =1 for Alfred at '&lt;SPAN&gt;04MAR14:23:57:00' and =1 for Mary at '&amp;nbsp;04MAR14:00:00:00'&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Oct 2018 18:46:23 GMT</pubDate>
    <dc:creator>lalaktgrau</dc:creator>
    <dc:date>2018-10-15T18:46:23Z</dc:date>
    <item>
      <title>Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504428#M134985</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have longitudinal data (one obs per person per minute) with the variables: ID, DateTime, and Disease. Disease is binary.&lt;/P&gt;&lt;P&gt;How can I identify the first occurrence of disease in this longitudinal data?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:42:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504428#M134985</guid>
      <dc:creator>lalaktgrau</dc:creator>
      <dc:date>2018-10-15T18:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504430#M134986</link>
      <description>&lt;P&gt;Plz post samples of your input and your required output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sure some genuises may be gauge from sentence based description but samples help test the solutions from responder's end&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:44:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504430#M134986</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T18:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504431#M134987</link>
      <description>&lt;P&gt;data WORK.CLASS;&lt;BR /&gt;infile datalines truncover;&lt;BR /&gt;input Name:$8.&amp;nbsp;disease datetime;&lt;BR /&gt;informat datetime datetime20.;&lt;BR /&gt;format datetime datetime20.;&lt;BR /&gt;datalines;&lt;BR /&gt;Alfred 0 04MAR14:23:55:00&lt;BR /&gt;Alfred 0 04MAR14:23:56:00&lt;BR /&gt;Alfred 1 04MAR14:23:57:00&lt;BR /&gt;Alfred 1 04MAR14:23:58:00&lt;BR /&gt;Alfred 1 04MAR14:23:59:00&lt;BR /&gt;Alfred 1 04MAR14:00:00:00&lt;BR /&gt;Alfred 1 04MAR14:01:01:00&lt;BR /&gt;Alfred 1 04MAR14:01:02:00&lt;BR /&gt;Alfred 1 04MAR14:01:03:00&lt;BR /&gt;Alfred 1 04MAR14:01:04:00&lt;/P&gt;&lt;P&gt;mary 0 04MAR14:23:55:00&lt;BR /&gt;mary 0 04MAR14:23:56:00&lt;BR /&gt;mary 0 04MAR14:23:57:00&lt;BR /&gt;mary 0 04MAR14:23:58:00&lt;BR /&gt;mary 0 04MAR14:23:59:00&lt;BR /&gt;mary 1 04MAR14:00:00:00&lt;BR /&gt;mary 1 04MAR14:01:01:00&lt;BR /&gt;mary 1 04MAR14:01:02:00&lt;BR /&gt;mary 1 04MAR14:01:03:00&lt;BR /&gt;mary 1 04MAR14:01:04:00&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like a variable that =1 just on the FIRST time disease=1. For example, the variable would =1 for Alfred at '&lt;SPAN&gt;04MAR14:23:57:00' and =1 for Mary at '&amp;nbsp;04MAR14:00:00:00'&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504431#M134987</guid>
      <dc:creator>lalaktgrau</dc:creator>
      <dc:date>2018-10-15T18:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504434#M134989</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 
data WORK.CLASS;
infile datalines truncover;
input Name:$8. disease datetime;
informat datetime datetime20.;
format datetime datetime20.;
datalines;
Alfred 0 04MAR14:23:55:00
Alfred 0 04MAR14:23:56:00
Alfred 1 04MAR14:23:57:00
Alfred 1 04MAR14:23:58:00
Alfred 1 04MAR14:23:59:00
Alfred 1 04MAR14:00:00:00
Alfred 1 04MAR14:01:01:00
Alfred 1 04MAR14:01:02:00
Alfred 1 04MAR14:01:03:00
Alfred 1 04MAR14:01:04:00
mary 0 04MAR14:23:55:00
mary 0 04MAR14:23:56:00
mary 0 04MAR14:23:57:00
mary 0 04MAR14:23:58:00
mary 0 04MAR14:23:59:00
mary 1 04MAR14:00:00:00
mary 1 04MAR14:01:01:00
mary 1 04MAR14:01:02:00
mary 1 04MAR14:01:03:00
mary 1 04MAR14:01:04:00
;

data want;
set class;
by name;
if first.name then temp=1;
temp+disease;
if temp=2;
drop temp;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Oct 2018 18:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504434#M134989</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T18:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504450#M134990</link>
      <description>&lt;P&gt;This works... but what if a person can fall in and out of disease? How can I identify each individual onset?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504450#M134990</guid>
      <dc:creator>lalaktgrau</dc:creator>
      <dc:date>2018-10-15T19:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504451#M134991</link>
      <description>&lt;P&gt;Can you clarify that point and post your required output plz&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504451#M134991</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T19:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504452#M134992</link>
      <description>&lt;P&gt;data WORK.CLASS;&lt;BR /&gt;infile datalines truncover;&lt;BR /&gt;input Name:$8.&amp;nbsp;disease datetime;&lt;BR /&gt;informat datetime datetime20.;&lt;BR /&gt;format datetime datetime20.;&lt;BR /&gt;datalines;&lt;BR /&gt;Alfred 0 04MAR14:23:55:00&lt;BR /&gt;Alfred 0 04MAR14:23:56:00&lt;BR /&gt;Alfred 1 04MAR14:23:57:00&lt;BR /&gt;Alfred 1 04MAR14:23:58:00&lt;BR /&gt;Alfred 0 04MAR14:23:59:00&lt;BR /&gt;Alfred 0 04MAR14:00:00:00&lt;BR /&gt;Alfred 1 04MAR14:01:01:00&lt;BR /&gt;Alfred 1 04MAR14:01:02:00&lt;BR /&gt;Alfred 1 04MAR14:01:03:00&lt;BR /&gt;Alfred 1 04MAR14:01:04:00&lt;/P&gt;&lt;P&gt;mary 0 04MAR14:23:55:00&lt;BR /&gt;mary 0 04MAR14:23:56:00&lt;BR /&gt;mary 0 04MAR14:23:57:00&lt;BR /&gt;mary 0 04MAR14:23:58:00&lt;BR /&gt;mary 0 04MAR14:23:59:00&lt;BR /&gt;mary 1 04MAR14:00:00:00&lt;BR /&gt;mary 0 04MAR14:01:01:00&lt;BR /&gt;mary 0 04MAR14:01:02:00&lt;BR /&gt;mary 1 04MAR14:01:03:00&lt;BR /&gt;mary 1 04MAR14:01:04:00&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we wanted the variable to =1 each time there is a new onset of disease? Changing from 0 to 1?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:36:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504452#M134992</guid>
      <dc:creator>lalaktgrau</dc:creator>
      <dc:date>2018-10-15T19:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504454#M134993</link>
      <description>&lt;P&gt;Do you mean you want to pick all the 1's?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An output sample for the input would help&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:39:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504454#M134993</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T19:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504456#M134995</link>
      <description>&lt;P&gt;I would want a variable to equal 1 whenever there is a change from 0 to 1.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504456#M134995</guid>
      <dc:creator>lalaktgrau</dc:creator>
      <dc:date>2018-10-15T19:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504458#M134996</link>
      <description>&lt;P&gt;may be this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.CLASS;
infile datalines truncover;
input Name:$8. disease datetime;
informat datetime datetime20.;
format datetime datetime20.;
datalines;
Alfred 0 04MAR14:23:55:00
Alfred 0 04MAR14:23:56:00
Alfred 1 04MAR14:23:57:00
Alfred 1 04MAR14:23:58:00
Alfred 0 04MAR14:23:59:00
Alfred 0 04MAR14:00:00:00
Alfred 1 04MAR14:01:01:00
Alfred 1 04MAR14:01:02:00
Alfred 1 04MAR14:01:03:00
Alfred 1 04MAR14:01:04:00
mary 0 04MAR14:23:55:00
mary 0 04MAR14:23:56:00
mary 0 04MAR14:23:57:00
mary 0 04MAR14:23:58:00
mary 0 04MAR14:23:59:00
mary 1 04MAR14:00:00:00
mary 0 04MAR14:01:01:00
mary 0 04MAR14:01:02:00
mary 1 04MAR14:01:03:00
mary 1 04MAR14:01:04:00
;

data want;
set class;
by name disease notsorted;
if first.disease and disease then flag=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 15 Oct 2018 19:42:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504458#M134996</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-15T19:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying onset in longitudinal data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504493#M135009</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.CLASS;
infile datalines truncover;
input Name:$8. disease datetime;
informat datetime datetime20.;
format datetime datetime20.;
datalines;
Alfred 0 04MAR14:23:55:00
Alfred 0 04MAR14:23:56:00
Alfred 1 04MAR14:23:57:00
Alfred 1 04MAR14:23:58:00
Alfred 0 04MAR14:23:59:00
Alfred 0 04MAR14:00:00:00
Alfred 1 04MAR14:01:01:00
Alfred 1 04MAR14:01:02:00
Alfred 1 04MAR14:01:03:00
Alfred 1 04MAR14:01:04:00
mary 0 04MAR14:23:55:00
mary 0 04MAR14:23:56:00
mary 0 04MAR14:23:57:00
mary 0 04MAR14:23:58:00
mary 0 04MAR14:23:59:00
mary 1 04MAR14:00:00:00
mary 0 04MAR14:01:01:00
mary 0 04MAR14:01:02:00
mary 1 04MAR14:01:03:00
mary 1 04MAR14:01:04:00
;

data want;
  set class;
  by name;
  flag= (first.name=1 and disease=1) or (dif(disease)=1);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DIF function is defined as&amp;nbsp;&amp;nbsp; dif(x)=x-lag(x).&amp;nbsp; So the condition "dif(disease)=1" picks up all instances of disease=1 that immediately follow a disease=0.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Oct 2018 21:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-onset-in-longitudinal-data/m-p/504493#M135009</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-10-15T21:03:41Z</dc:date>
    </item>
  </channel>
</rss>

