<?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: Calculate difference between columns for rows when a string condition is found in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-between-columns-for-rows-when-a-string/m-p/676660#M204049</link>
    <description>It works thanks. I forgot to define the format</description>
    <pubDate>Fri, 14 Aug 2020 08:52:15 GMT</pubDate>
    <dc:creator>ACLAN</dc:creator>
    <dc:date>2020-08-14T08:52:15Z</dc:date>
    <item>
      <title>Calculate difference between columns for rows when a string condition is found</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-between-columns-for-rows-when-a-string/m-p/676658#M204047</link>
      <description>&lt;P&gt;I'm trying to correct the values in a specific columns for rows in which a specific condition is found.&lt;/P&gt;&lt;P&gt;Using the following dataset as example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; dttest;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; patient_id $ patient_name $ (enttime draw1 tdiff) (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#404000"&gt;time8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; +&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#00ae00"&gt;1&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; enttime draw1 tdiff &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#404000"&gt;time8.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;18C020 Garcia 11:45:00 11:50:00 00:07:00&lt;/P&gt;&lt;P&gt;17C222 Gibson 11:43:00 11:47:00 00:04:00&lt;/P&gt;&lt;P&gt;18C023 Knapp 11:42:00 11:45:00 00:43:00&lt;/P&gt;&lt;P&gt;10C032 Mueller 09:11:00 11:47:00 02:36:00&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;run&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the rows where patient_id has "18C", I would like to correct the values in column tdiff by subtracting the time in colum draw1 from the time in column enttime.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried IF/THEN and WHERE to select the rows but I always have an error. Not sure if it is a good idea to create an array. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone has a simple solution for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2020 08:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-between-columns-for-rows-when-a-string/m-p/676658#M204047</guid>
      <dc:creator>ACLAN</dc:creator>
      <dc:date>2020-08-14T08:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between columns for rows when a string condition is found</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-between-columns-for-rows-when-a-string/m-p/676659#M204048</link>
      <description>&lt;P&gt;Please try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dttest;
input patient_id $ patient_name $ (enttime draw1 tdiff) (time8. +1);
format enttime draw1 tdiff time8.;
datalines;
18C020 Garcia 11:45:00 11:50:00 00:07:00
17C222 Gibson 11:43:00 11:47:00 00:04:00
18C023 Knapp 11:42:00 11:45:00 00:43:00
10C032 Mueller 09:11:00 11:47:00 02:36:00
;
run;

data want;
set dttest;
if index(patient_id,'18C') then tdiff=draw1-enttime;
format tdiff time8.;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2020 08:47:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-between-columns-for-rows-when-a-string/m-p/676659#M204048</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-08-14T08:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between columns for rows when a string condition is found</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-between-columns-for-rows-when-a-string/m-p/676660#M204049</link>
      <description>It works thanks. I forgot to define the format</description>
      <pubDate>Fri, 14 Aug 2020 08:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-difference-between-columns-for-rows-when-a-string/m-p/676660#M204049</guid>
      <dc:creator>ACLAN</dc:creator>
      <dc:date>2020-08-14T08:52:15Z</dc:date>
    </item>
  </channel>
</rss>

