<?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: Flag first diagnosis beginning with &amp;quot;S06&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/277694#M55783</link>
    <description>&lt;P&gt;If you don't mind sorting your data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have; by person_id Encounter_Date DxCode; run;

data want;
set have;
by person_id Encounter_Date DxCode;
flag = first.DxCode and DxCode =: "S06";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 15 Jun 2016 21:52:02 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-06-15T21:52:02Z</dc:date>
    <item>
      <title>Flag first diagnosis beginning with "S06"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/277689#M55780</link>
      <description>&lt;P&gt;I have a table with columns for person_id, Encounter_Date, Diagnosis1-10, and&amp;nbsp;DxCode. How can i flag the first DxCode that starts with "S06" for each separate person_id and&amp;nbsp;Encounter_Date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Brian&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 21:24:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/277689#M55780</guid>
      <dc:creator>BTAinRVA</dc:creator>
      <dc:date>2016-06-15T21:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: Flag first diagnosis beginning with "S06"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/277694#M55783</link>
      <description>&lt;P&gt;If you don't mind sorting your data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have; by person_id Encounter_Date DxCode; run;

data want;
set have;
by person_id Encounter_Date DxCode;
flag = first.DxCode and DxCode =: "S06";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jun 2016 21:52:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/277694#M55783</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-06-15T21:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: Flag first diagnosis beginning with "S06"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/277705#M55790</link>
      <description>&lt;P&gt;Starts with makes it a bit more difficult.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you'll have to create an array of the diags and loop over them unfortunately. If it was full code I would use WHICHC Function.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/277705#M55790</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-15T22:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Flag first diagnosis beginning with "S06"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/277710#M55793</link>
      <description>&lt;P&gt;Here's what I think you are looking for:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;sort&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; person_id Encounter_Date&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; want&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token statement"&gt;by&lt;/SPAN&gt; person_id Encounter_Date&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;if first.Encounter_Date then do;&lt;BR /&gt;   flag=0;&lt;BR /&gt;   S06_found=0;&lt;BR /&gt;end;&lt;BR /&gt;retain flag S06_found;&lt;BR /&gt;if DxCode =: 'S06' then do;&lt;BR /&gt;   S06_found + 1;&lt;BR /&gt;   if S06_found=1 then flag=1;&lt;BR /&gt;   else flag=0;&lt;BR /&gt;end;&lt;BR /&gt;else flag=0;&lt;BR /&gt;drop S06_found;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It gets a little tricky because there can be multiple, different Dx Codes that begin with S06 on the same date.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/277710#M55793</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-15T23:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Flag first diagnosis beginning with "S06"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/278043#M55909</link>
      <description>&lt;P&gt;PG,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the reply. I was able to get it to work with some minor tweaks (needed because i didn't explain my problem well enough).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Brian&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 21:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flag-first-diagnosis-beginning-with-quot-S06-quot/m-p/278043#M55909</guid>
      <dc:creator>BTAinRVA</dc:creator>
      <dc:date>2016-06-16T21:26:56Z</dc:date>
    </item>
  </channel>
</rss>

