<?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 longitudinal data: counting observations after a date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685319#M207838</link>
    <description>&lt;P&gt;Hi experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am not comfortable uploading any dataset, but does any of you have a piece of code to count observations after a certain date?&lt;BR /&gt;&lt;BR /&gt;My dataset contains of patient ids (with 1-6 observations), a measurement parameter and dates of diagnosis 1 and 2 (two variables with dates).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to know how many observations participants have before and after the diagnoses (if any).&amp;nbsp;&lt;/P&gt;&lt;P&gt;And further, can this be illustrated by some plot? I have made spaghetti-plots for each participant to illustrate when in time they have the measurements made, but I don't know how to integrate the dates, so I can "mark" the timepoint.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I hope, you can help me.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Sep 2020 07:47:03 GMT</pubDate>
    <dc:creator>lone0708</dc:creator>
    <dc:date>2020-09-21T07:47:03Z</dc:date>
    <item>
      <title>longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685319#M207838</link>
      <description>&lt;P&gt;Hi experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am not comfortable uploading any dataset, but does any of you have a piece of code to count observations after a certain date?&lt;BR /&gt;&lt;BR /&gt;My dataset contains of patient ids (with 1-6 observations), a measurement parameter and dates of diagnosis 1 and 2 (two variables with dates).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to know how many observations participants have before and after the diagnoses (if any).&amp;nbsp;&lt;/P&gt;&lt;P&gt;And further, can this be illustrated by some plot? I have made spaghetti-plots for each participant to illustrate when in time they have the measurements made, but I don't know how to integrate the dates, so I can "mark" the timepoint.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I hope, you can help me.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 07:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685319#M207838</guid>
      <dc:creator>lone0708</dc:creator>
      <dc:date>2020-09-21T07:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685332#M207843</link>
      <description>&lt;P&gt;This is unclear. If you have 6 observations, you have 12 diagnosis dates.&lt;/P&gt;
&lt;P&gt;Please provide simple sample data and desired output.&lt;/P&gt;
&lt;P&gt;Same for the plot you'd like. Show us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 08:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685332#M207843</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-21T08:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685378#M207863</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Hi ChrisNZ,&lt;BR /&gt;&lt;BR /&gt;Does this help?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;The desired output is a table, where&amp;nbsp;I can get an overview of the participants and how many measurements, they have after each date.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;A table with a summary of the total numbers of measurements after the dates, will also be helpfull.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Regarding the plot,&amp;nbsp;I am actually not sure how to get it illustrated, but&amp;nbsp;I figured a spaghetti-plot for peach patient with maybe a change in&amp;nbsp;colour or mark of when the date of diagnosis has passed.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;BR /&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp;have;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;input&lt;/SPAN&gt; patientid visit_date measure d_dx1 dx2;&lt;/P&gt;&lt;P&gt;datalines&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;010118&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;3.4 010118 100118&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;050518&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;2.3 010118 100118&lt;/P&gt;&lt;P&gt;2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;100217&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;7.3 050217 .&lt;/P&gt;&lt;P&gt;2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;170217&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;7.2 050217 .&lt;/P&gt;&lt;P&gt;2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;200217&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;7.1 050217 .&lt;/P&gt;&lt;P&gt;3&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;210217&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;5.4 210217 250217&lt;/P&gt;&lt;P&gt;4&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;020218&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;3.4 010118 020218&lt;/P&gt;&lt;P&gt;4&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;040218&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;3.2 010118 020218&lt;/P&gt;&lt;P&gt;5&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;040518&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;5.6 .&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;030518&lt;/P&gt;&lt;P&gt;5&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;050518&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;5.0 .&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;030518&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 11:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685378#M207863</guid>
      <dc:creator>lone0708</dc:creator>
      <dc:date>2020-09-21T11:16:14Z</dc:date>
    </item>
    <item>
      <title>counting observations after certain date, longitudinal measurements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685430#M207884</link>
      <description>&lt;P&gt;Hi experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;i am not comfortable uploading any dataset, but does any of you have a piece of code to count observations after a certain date?&lt;BR /&gt;&lt;BR /&gt;My dataset contains of patient ids (with 1-6 observations), a measurement parameter and dates of diagnosis 1 and 2 (two variables with dates).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to know how many observations participants have before and after the diagnoses (if any).&amp;nbsp;&lt;/P&gt;&lt;P&gt;And further, can this be illustrated by some plot? I have made spaghetti-plots for each participant to illustrate when in time they have the measurements made, but I don't know how to integrate the dates, so I can "mark" the timepoint.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;The desired output is a table, where&amp;nbsp;I can get an overview of the participants and how many measurements, they have after each date.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;A table with a summary of the total numbers of measurements after the dates, will also be helpfull.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Regarding the plot,&amp;nbsp;I am actually not sure how to get it illustrated, but&amp;nbsp;I figured a spaghetti-plot for peach patient with maybe a change in&amp;nbsp;colour or mark of when the date of diagnosis has passed.&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;&lt;BR /&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&amp;nbsp;have;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;input&lt;/SPAN&gt; patientid visit_date measure d_dx1 dx2;&lt;/P&gt;&lt;P&gt;datalines&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;010118&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;3.4 010118 100118&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;050518&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;2.3 010118 100118&lt;/P&gt;&lt;P&gt;2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;100217&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;7.3 050217 .&lt;/P&gt;&lt;P&gt;2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;170217&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;7.2 050217 .&lt;/P&gt;&lt;P&gt;2&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;200217&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;7.1 050217 .&lt;/P&gt;&lt;P&gt;3&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;210217&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;5.4 210217 250217&lt;/P&gt;&lt;P&gt;4&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;020218&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;3.4 010118 020218&lt;/P&gt;&lt;P&gt;4&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;040218&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;3.2 010118 020218&lt;/P&gt;&lt;P&gt;5&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;040518&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;5.6 .&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;030518&lt;/P&gt;&lt;P&gt;5&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;050518&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &lt;/SPAN&gt;5.0 .&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;030518&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I hope, you can help me.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 13:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685430#M207884</guid>
      <dc:creator>lone0708</dc:creator>
      <dc:date>2020-09-21T13:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685449#M207882</link>
      <description>&lt;P&gt;One of the first things to do when asking about "specific date" is to make sure that your variables are actually dates.&lt;/P&gt;
&lt;P&gt;The code you show has a simple numeric. And from the values given it really isn't possible to tell if the values are in a ddmmyy or yymmdd layout.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In case no one has mentioned this: 2 digit years are double-plus ungood.&lt;/P&gt;
&lt;P&gt;If your values are day month year then "greater than" is really going to need a SAS date value because the current values you show such as 050518 would not be less than 010119.&lt;/P&gt;
&lt;P&gt;See if the formatted dates in this match your expectation. This is one example of how to read dates.&lt;/P&gt;
&lt;PRE&gt;data have;
   input patientid visit_date :ddmmyy6. measure d_dx1 :ddmmyy6. dx2 :ddmmyy6.;
   format  visit_date d_dx1 dx2 date9.;
datalines;
1  010118  3.4 010118 100118 
1  050518  2.3 010118 100118
2  100217  7.3 050217 .
2  170217  7.2 050217 .
2  200217  7.1 050217 .
3  210217  5.4 210217 250217
4  020218  3.4 010118 020218
4  040218  3.2 010118 020218
5  040518  5.6 .      030518
5  050518  5.0 .      030518
;
run;&lt;/PRE&gt;
&lt;P&gt;Then tell use which value we are supposed to be comparing for "after a date". AS in by variable name and the rules concerned.&lt;/P&gt;
&lt;P&gt;For the type of plot, with a marker at diagnosis, you would want to have a single value for the diagnosis date per patient and likely the measure corresponding to that date, assuming by spaghetti-plot you were plotting the measure value per visit date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Sep 2020 14:41:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685449#M207882</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-21T14:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: counting observations after certain date, longitudinal measurements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685564#M207939</link>
      <description>&lt;P&gt;&amp;gt;&lt;EM&gt;I hope, you can help me.&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;You need to help yourself first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned these dates does not look like dates. Are they just a number to be interpreted as a date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;More importantly we still have no idea what result you want.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 03:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685564#M207939</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-22T03:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685610#M207955</link>
      <description>&lt;P&gt;Dear ballardw,&lt;/P&gt;&lt;P&gt;i am sorry that i am not so familiar in working with SAS.&lt;BR /&gt;The format you added for the dates are the right ones&amp;nbsp;- thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not need to compare values, i need to get a count of how many have measurements (how many observations per patientid) before and on/after the two diagnosis dates (dx1 and dx2) respectively.&lt;/P&gt;&lt;P&gt;First as an overview of all participants with a line for each patient&amp;nbsp;forexample:&lt;/P&gt;&lt;P&gt;patientid&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; count before dx1&amp;nbsp; count after dx1 count after dx2&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then an overview of all (as in proc freq) (i just added some random numbers below):&lt;/P&gt;&lt;P&gt;n (patients)&amp;nbsp;&amp;nbsp; count before dx1&amp;nbsp; count after dx1&amp;nbsp;&amp;nbsp; count after dx2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding the plot: sounds like a good idea with your suggestion. Can you tell me how to make a corresponding measure variable via a SAS code?&lt;BR /&gt;&lt;BR /&gt;Thanks for your help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 07:56:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685610#M207955</guid>
      <dc:creator>lone0708</dc:creator>
      <dc:date>2020-09-22T07:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685629#M207970</link>
      <description>&lt;P&gt;First, let's read your data in unambiguous manner, and create two datasets to avoid wasting space for redundant information:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data patients;
input patientid $ (dx1 dx2) (:yymmdd8.);
format dx1 dx2 yymmdd10.;
datalines;
1 20180101 20180101
2 20170205 .
3 20170221 20170225
4 20180101 20180202
5 . 20180503
;

data visits;
input patientid $ visit_date :yymmdd8. measure;
format visit_date yymmdd10.;
datalines;
1  20180101  3.4
1  20180505  2.3
2  20170210  7.3
2  20170217  7.2
2  20170220  7.1
3  20170221  5.4
4  20180202  3.4
4  20180204  3.2
5  20180504  5.6
5  20180505  5.0
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you use BY processing in a DATA step to create the counts:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge
  patients
  visits
;
by patientid;
if first.patientid
then do;
  count_before_dx1 = 0;
  count_after_dx1 = 0;
  count_after_dx2 = 0;
end;
if dx1 ne .
then do;
  if visit_date lt dx1
  then count_before_dx1 + 1;
  if visit_date gt dx1
  then count_after_dx1 + 1;
end;
if visit_date gt dx2 and dx2 ne .
then count_after_dx2 + 1;
if last.patientid;
keep patientid count_before_dx1 count_after_dx1 count_after_dx2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You may need to tweak the conditions to get the counts you want (le/ge instead of lt/gt, or omit the checks for missing).&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 09:16:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685629#M207970</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-22T09:16:35Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685689#M207996</link>
      <description>Amazing! Thank you Kurtbremser, it works!&lt;BR /&gt;okay - well, the only adjustment i need to do now, is if a person is missing a diagnosis. Right now the count occur as "0", but the diagnosis were never there, so how do i correct that to just "." without ruining the true "0"s ?</description>
      <pubDate>Tue, 22 Sep 2020 13:17:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685689#M207996</guid>
      <dc:creator>lone0708</dc:creator>
      <dc:date>2020-09-22T13:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685692#M207997</link>
      <description>&lt;P&gt;After the subsetting IF, you can add logic for missing dx1/dx2.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Sep 2020 13:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685692#M207997</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-22T13:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685962#M208085</link>
      <description>Thanks for your quick replies,&lt;BR /&gt;I can't make it work with the logic for missing dx1/dx2.&lt;BR /&gt;Is it possible for you to write it in the code, please?&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Sep 2020 06:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685962#M208085</guid>
      <dc:creator>lone0708</dc:creator>
      <dc:date>2020-09-23T06:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685963#M208086</link>
      <description>&lt;P&gt;A simple IF-THEN:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if dx1 = . then count_before_dx1 = .;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Likewise for the other counts.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 06:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685963#M208086</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-23T06:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685969#M208091</link>
      <description>Thank you very much for your patience &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; This saved me hours!</description>
      <pubDate>Wed, 23 Sep 2020 07:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685969#M208091</guid>
      <dc:creator>lone0708</dc:creator>
      <dc:date>2020-09-23T07:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685977#M208093</link>
      <description>okay , now I am trying to also integrate count_before_dx2, but I can't find out where to put it in the code.&lt;BR /&gt;The output showed me "0" I the cells even though my code looks like this:&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;merge&lt;BR /&gt;patients&lt;BR /&gt;visits&lt;BR /&gt;;&lt;BR /&gt;by patientid;&lt;BR /&gt;if first.patientid&lt;BR /&gt;then do;&lt;BR /&gt;count_before_dx1 = 0;&lt;BR /&gt;count_before_dx2 = 0;&lt;BR /&gt;count_after_dx1 = 0;&lt;BR /&gt;count_after_dx2 = 0;&lt;BR /&gt;end;&lt;BR /&gt;if dx1 ne .&lt;BR /&gt;then do;&lt;BR /&gt;if visit_date lt dx1&lt;BR /&gt;then count_before_dx1 + 1;&lt;BR /&gt;if visit_date lt dx2&lt;BR /&gt;then count_before_dx2 + 1;&lt;BR /&gt;if visit_date ge dx1&lt;BR /&gt;then count_after_dx1 + 1;&lt;BR /&gt;end;&lt;BR /&gt;if visit_date lt dx2&lt;BR /&gt;then count_before_dx2 + 1;&lt;BR /&gt;if visit_date gt dx2 and dx2 ne .&lt;BR /&gt;then count_after_dx2 + 1;&lt;BR /&gt;if dx1 = . then count_before_dx1 = .;&lt;BR /&gt;if dx2 = . then count_before_dx2 = .;&lt;BR /&gt;if dx1 = . then count_after_dx1 = .;&lt;BR /&gt;if dx2 = . then count_after_dx2 = .;&lt;BR /&gt;if last.patientid;&lt;BR /&gt;keep patientid count_before_dx1 count_after_dx1 count_after_dx2 count_before_dx2;&lt;BR /&gt;run;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Sep 2020 08:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/685977#M208093</guid>
      <dc:creator>lone0708</dc:creator>
      <dc:date>2020-09-23T08:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: longitudinal data: counting observations after a date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/686088#M208133</link>
      <description>&lt;P&gt;I have revised the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge
  patients
  visits
;
by patientid;
if first.patientid
then do;
  count_before_dx1 = 0;
  count_before_dx2 = 0;
  count_after_dx1 = 0;
  count_after_dx2 = 0;
end;
if visit_date lt dx1 then count_before_dx1 + 1;
if visit_date lt dx2 then count_before_dx2 + 1;
if visit_date ge dx1 then count_after_dx1 + 1;
if visit_date ge dx2 then count_after_dx2 + 1;
if last.patientid;
if dx1 = .
then do;
  count_before_dx1 = .;
  count_after_dx1 = .;
end;
if dx2 = .
then do;
  count_before_dx2 = .;
  count_after_dx2 = .;
end;
keep patientid count_before_dx1 count_after_dx1 count_after_dx2 count_before_dx2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please use the "little running man" button to post the code, otherwise the main posting window will destroy the formatting.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 15:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/longitudinal-data-counting-observations-after-a-date/m-p/686088#M208133</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-23T15:13:33Z</dc:date>
    </item>
  </channel>
</rss>

