<?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: Finding the ICD diagnosis for earliest date in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699697#M25644</link>
    <description>I want one observation per line with the earliest date for each observation</description>
    <pubDate>Wed, 18 Nov 2020 08:35:33 GMT</pubDate>
    <dc:creator>mantubiradar19</dc:creator>
    <dc:date>2020-11-18T08:35:33Z</dc:date>
    <item>
      <title>Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699692#M25641</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have A CSV file containing the list of individuals with their ICD diagnosis on multiple dates. The data looks as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="339"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="78"&gt;ID&lt;/TD&gt;
&lt;TD width="85"&gt;ICD VERSION&lt;/TD&gt;
&lt;TD width="65"&gt;ICD CODE&lt;/TD&gt;
&lt;TD width="111"&gt;DIAGNOSIS DATE&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;M0058&lt;/TD&gt;
&lt;TD&gt;ICD-9&lt;/TD&gt;
&lt;TD&gt;733.42&lt;/TD&gt;
&lt;TD&gt;19-06-14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;M0058&lt;/TD&gt;
&lt;TD&gt;ICD-9&lt;/TD&gt;
&lt;TD&gt;733.42&lt;/TD&gt;
&lt;TD&gt;19-09-14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;M0058&lt;/TD&gt;
&lt;TD&gt;ICD-9&lt;/TD&gt;
&lt;TD&gt;733.42&lt;/TD&gt;
&lt;TD&gt;18-12-14&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;M0058&lt;/TD&gt;
&lt;TD&gt;ICD-9&lt;/TD&gt;
&lt;TD&gt;733.42&lt;/TD&gt;
&lt;TD&gt;03-12-15&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;M0058&lt;/TD&gt;
&lt;TD&gt;ICD-9&lt;/TD&gt;
&lt;TD&gt;733.42&lt;/TD&gt;
&lt;TD&gt;24-12-15&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;M0058&lt;/TD&gt;
&lt;TD&gt;ICD-9&lt;/TD&gt;
&lt;TD&gt;733.42&lt;/TD&gt;
&lt;TD&gt;31-12-15&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create a new SAS dataset with the list of observations along with their first ICD diagnosis. For the above case, I would like to retain only "M000000058" "ICD-9" "733.42" "19-06-14"&lt;BR /&gt;Thanks in advance&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 08:17:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699692#M25641</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2020-11-18T08:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699695#M25642</link>
      <description>&lt;P&gt;Sort by id and date, then run&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by id;
if first.id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or (no preceding sort needed, but may perform worse)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select *
  from have
  group by id
  having date = min(date)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Nov 2020 08:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699695#M25642</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-18T08:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699696#M25643</link>
      <description>&lt;P&gt;So you still want as many observations as in the original data?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 08:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699696#M25643</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-18T08:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699697#M25644</link>
      <description>I want one observation per line with the earliest date for each observation</description>
      <pubDate>Wed, 18 Nov 2020 08:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699697#M25644</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2020-11-18T08:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699698#M25645</link>
      <description>Thanks, Kurt, After importing the CSV the "DIAGNOSIS_DATE" has a character type. Do I need to change this date format before sorting?</description>
      <pubDate>Wed, 18 Nov 2020 08:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699698#M25645</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2020-11-18T08:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699701#M25646</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16379"&gt;@mantubiradar19&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks, Kurt, After importing the CSV the "DIAGNOSIS_DATE" has a character type. Do I need to change this date format before sorting?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Absolutely. Obvious date values must always be imported as SAS date values to be useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, anybody who sends you dates with two-digit years needs to be beat over the head with a medium-sized reinforced-concrete pillar. After Y2K, I consider anybody doing this as having an IQ lower than the number of years passed since 2000.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get help for correctly reading your data, please open the CSV file with an editor (NOT WITH EXCEL!!) and copy/paste the first 10 lines into a window opened with this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/70F8802BAA6255D55FBEC62A8226FB10/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 08:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699701#M25646</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-18T08:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699704#M25647</link>
      <description>&lt;PRE&gt;"ID","ICD VERSION","ICD CODE","DIAGNOSIS DATE"
"M0058","ICD-9","733.42","2014/06/19"
"M0058","ICD-9","733.42","2014/09/19"
"M0058","ICD-9","733.42","2014/12/18"
"M0058","ICD-9","733.42","2015/12/03"
"M0058","ICD-9","733.42","2015/12/24"
"M0058","ICD-9","733.42","2015/12/31"
"M00331","ICD-10-CM","M81.0","2020/04/03"
"M00331","ICD-10-CM","M81.0","2020/04/07"
"M00331","ICD-10-CM","M81.0","2020/04/10"&lt;/PRE&gt;
&lt;P&gt;Here you go!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 08:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699704#M25647</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2020-11-18T08:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699710#M25648</link>
      <description>&lt;P&gt;See?&lt;/P&gt;
&lt;P&gt;You showed us what Excel showed you, and that sparked my comment about 2-digit years. Now we see that the file has in fact very sensible date values in ISO format, as it should be.&lt;/P&gt;
&lt;P&gt;Moral: never use Excel to look at text files.&lt;/P&gt;
&lt;P&gt;Use this code to import that file:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data import;
infile "your_file_name" dlm="," dsd firstobs=2 truncover;
input
  id :$10.
  icd_version :$10.
  icd_code :$8.
  diagnosis_date :yymmdd10.
;
format diagnosis_date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that throws NOTEs about invalid values for diagnosis_date, post one of those messages (including the listing of the raw data line) as you posted the file data. We can then see what we need to do to avoid that NOTE, as you want a clean log (Maxim 25).&lt;/P&gt;
&lt;P&gt;I suspect that all the data was imported as character because PROC IMPORT was misled by the quotes around the date values.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 09:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699710#M25648</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-18T09:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699711#M25649</link>
      <description>&lt;P&gt;PS adapt the lengths of the character informats as needed. The lengths I use are guesses.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 09:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699711#M25649</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-18T09:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699714#M25650</link>
      <description>Thank you so much for your advice Kurt, let me try this</description>
      <pubDate>Wed, 18 Nov 2020 09:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699714#M25650</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2020-11-18T09:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699720#M25652</link>
      <description>I was able to import the CSV file using your code and sort by id and diagnosis_date to obtain unique observations with the earliest diagnosis date (using Sort by id and date, then run). For your reference, I used the following import code earlier:&lt;BR /&gt;&lt;BR /&gt;%let path=PATH;&lt;BR /&gt;options validvarname=v7;&lt;BR /&gt;&lt;BR /&gt;proc import datafile="&amp;amp;path\My_CSV.csv"&lt;BR /&gt;out=MY_CSV&lt;BR /&gt;dbms=csv;&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;run;quit; &lt;BR /&gt;</description>
      <pubDate>Wed, 18 Nov 2020 09:42:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699720#M25652</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2020-11-18T09:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699783#M25657</link>
      <description>Can you please tell me what is the function of "dsd firstobs=2 truncover;"?</description>
      <pubDate>Wed, 18 Nov 2020 13:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699783#M25657</guid>
      <dc:creator>mantubiradar19</dc:creator>
      <dc:date>2020-11-18T13:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Finding the ICD diagnosis for earliest date</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699787#M25658</link>
      <description>&lt;P&gt;DSD means "delimiter sensitive data". It has three effects: quotes around values are removed, delimiters within the quoted string a re disregarded, and two or more delimiters in succession mean that there are missing values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FIRSTOBS= instructs the data step to skip lines at the beginning, FIRSTOBS=2 means skipping a single header line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TRUNCOVER controls what should happen if not enough data is found to fill all columns in the INPUT statement. TRUNCOVER means that any shorter value is still used to fill a column, and any subsequent columns are set to missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All these options are described in detail in the documentation of the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=n1rill4udj0tfun1fvce3j401plo.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;INFILE Statement&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 13:16:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Finding-the-ICD-diagnosis-for-earliest-date/m-p/699787#M25658</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-18T13:16:56Z</dc:date>
    </item>
  </channel>
</rss>

