<?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: first date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/first-date/m-p/501681#M133802</link>
    <description>&lt;P&gt;I don't see any error.&lt;/P&gt;
&lt;P&gt;You have a note informing you of the type of processing you requested when asking for the table data to be matched to its summarized data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Oct 2018 19:58:10 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2018-10-04T19:58:10Z</dc:date>
    <item>
      <title>first date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-date/m-p/500988#M133509</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this output from the code below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to only see the first diagnosis and first treatment date for each patient for each drug.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example for patient_id 2038 i want to see diagnosis_date = 01/21/2010,&amp;nbsp; treatment_date= 01/24/2010 for drug_code = A AND&amp;nbsp;&lt;/P&gt;&lt;P&gt;diagnosis_date = 01/21/2010, treatment_date=01/24/2010 for drug_code = B&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For patient_id 2120 i want to see diagnosis_date=01/09/2010 , treatment_date= 01/23/2010 for drug_code = B and&amp;nbsp;&lt;/P&gt;&lt;P&gt;diagnosis_date = 01/09/2010 , treatment_date = 01/24/2010 for drug_code = A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;	
	create table _00_diag_trt as 
	select distinct a.*, b.* 
	from pt_diag as a 
	full join pt_trt as b 
	on a.patient_id = b.patient_id
	order by a.patient_id , a.diagnosis_date ,b.treatment_date,b.drug_code;
quit;

proc print ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Obs	patient_id	diagnosis_date	diagnosis_code	diagnosis	treatment_date	drug_code
1	2038	01/21/2010	174.9	Breast Cancer	01/24/2010	A
2	2038	01/21/2010	174.9	Breast Cancer	01/24/2010	B
3	2038	01/21/2010	174.9	Breast Cancer	01/27/2010	A
4	2038	01/21/2010	174.9	Breast Cancer	01/27/2010	B
5	2038	01/21/2010	174.9	Breast Cancer	01/30/2010	A
6	2038	01/21/2010	174.9	Breast Cancer	01/30/2010	B
7	2038	01/21/2010	174.9	Breast Cancer	02/02/2010	A
8	2038	01/21/2010	174.9	Breast Cancer	02/06/2010	A
9	2038	01/21/2010	174.9	Breast Cancer	02/11/2010	A
10	2038	01/21/2010	174.9	Breast Cancer	02/18/2010	A
11	2038	01/21/2010	174.9	Breast Cancer	02/20/2010	A
12	2038	01/21/2010	174.9	Breast Cancer	01/24/2017	A
13	2038	01/21/2010	174.9	Breast Cancer	01/27/2017	A
14	2038	01/21/2010	174.9	Breast Cancer	01/30/2017	A
15	2038	01/21/2010	174.9	Breast Cancer	02/02/2017	A
16	2038	01/21/2010	174.9	Breast Cancer	02/06/2017	A
17	2038	01/21/2010	174.9	Breast Cancer	02/11/2017	A
18	2038	01/21/2010	174.9	Breast Cancer	02/18/2017	A
19	2038	01/21/2010	174.9	Breast Cancer	02/20/2017	A
20	2120	01/09/2010	174.1	Breast Cancer	01/23/2010	B
21	2120	01/09/2010	174.1	Breast Cancer	01/24/2010	A
22	2120	01/09/2010	174.1	Breast Cancer	01/26/2010	A
23	2120	01/09/2010	174.1	Breast Cancer	01/26/2010	B
24	2120	01/09/2010	174.1	Breast Cancer	01/27/2010	A
25	2120	01/09/2010	174.1	Breast Cancer	01/27/2010	B
26	2120	01/09/2010	174.1	Breast Cancer	01/29/2010	A
27	2120	01/09/2010	174.1	Breast Cancer	01/29/2010	B
28	2120	01/09/2010	174.1	Breast Cancer	02/01/2010	A
29	2120	01/09/2010	174.1	Breast Cancer	02/01/2010	B
30	2120	01/09/2010	174.1	Breast Cancer	02/04/2010	A
31	2120	01/09/2010	174.1	Breast Cancer	02/04/2010	B
32	2120	01/09/2010	174.1	Breast Cancer	02/07/2010	A
33	2120	01/09/2010	174.1	Breast Cancer	02/07/2010	B
34	2120	01/09/2010	174.1	Breast Cancer	02/10/2010	A
35	2120	01/09/2010	174.1	Breast Cancer	02/10/2010	B
36	2120	01/09/2010	174.1	Breast Cancer	02/14/2010	A
37	2120	01/09/2010	174.1	Breast Cancer	02/14/2010	B
38	2120	01/09/2010	174.1	Breast Cancer	02/18/2010	A
39	2120	01/09/2010	174.1	Breast Cancer	02/18/2010	B
40	2120	01/09/2010	174.1	Breast Cancer	02/22/2010	A
41	2120	01/09/2010	174.1	Breast Cancer	02/22/2010	B
42	2120	01/09/2010	174.1	Breast Cancer	02/27/2010	A
43	2120	01/09/2010	174.1	Breast Cancer	02/27/2010	B
44	2120	01/09/2010	174.1	Breast Cancer	03/02/2010	A
45	2120	01/09/2010	174.1	Breast Cancer	03/02/2010	B&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Oct 2018 22:52:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-date/m-p/500988#M133509</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-10-02T22:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: first date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-date/m-p/501001#M133517</link>
      <description>&lt;P&gt;2 solutions:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Sort by drug code&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;order &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; a&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;patient_id&lt;SPAN class="token punctuation"&gt;, b.drug_code,&lt;/SPAN&gt; a&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;diagnosis_date&lt;SPAN class="token punctuation"&gt;, &lt;/SPAN&gt;b&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;treatment_date&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;then use a data step keeping only first.&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token punctuation"&gt;drug_code&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;by PATIENT_ID DRUG_CODE;
if first.DRUG_CODE;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token punctuation"&gt;2. Add a &lt;FONT face="courier new,courier"&gt;group by&lt;/FONT&gt; clause in SQL to group by&amp;nbsp;PATIENT_ID, DRUG_CODE and add a &lt;FONT face="courier new,courier"&gt;having&lt;/FONT&gt; clause to keep the record with the lowest (minimum) date in each group.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 01:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-date/m-p/501001#M133517</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-10-03T01:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: first date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-date/m-p/501572#M133742</link>
      <description>&lt;P&gt;can you please write the code for sql option 2 ?&lt;/P&gt;&lt;P&gt;This is what i have but i am getting this error&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;147        proc sql;
 148        create table _01_ttr as
 149        select distinct min(treatment_date) as first_trt, patient_id, diagnosis_date, drug_code
 150        from _01_diag_trt
 151        group by patient_id,drug_code
 152        having min(treatment_date);
 NOTE: The query requires remerging summary statistics back with the original data.
 NOTE: Table WORK._01_TTR created, with 90 rows and 4 columns.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Oct 2018 16:32:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-date/m-p/501572#M133742</guid>
      <dc:creator>manya92</dc:creator>
      <dc:date>2018-10-04T16:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: first date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/first-date/m-p/501681#M133802</link>
      <description>&lt;P&gt;I don't see any error.&lt;/P&gt;
&lt;P&gt;You have a note informing you of the type of processing you requested when asking for the table data to be matched to its summarized data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 19:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/first-date/m-p/501681#M133802</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-10-04T19:58:10Z</dc:date>
    </item>
  </channel>
</rss>

