<?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: Help: Retrieve value from a column if a certain condition is met in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-Retrieve-value-from-a-column-if-a-certain-condition-is-met/m-p/888303#M43416</link>
    <description>&lt;P&gt;Please provide your sample data and the desired outcome using this sample data via a working SAS data step that creates such data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have a much better chance of anyone actually providing tested code if we don't have to spend time creating such sample SAS datasets prior to actually creating the code you're after.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Aug 2023 09:09:40 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2023-08-08T09:09:40Z</dc:date>
    <item>
      <title>Help: Retrieve value from a column if a certain condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-Retrieve-value-from-a-column-if-a-certain-condition-is-met/m-p/888302#M43415</link>
      <description>&lt;P&gt;Dear SAS experts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset containing coordinates for moving persons with a new latitude and longitude for every 10 seconds. The dataset also contains coordinates for their goal location. I would like to create a new column showing the time value when a person reaches the goal location (i.e. latitudeX and longitudeX match goal_latitude and goal_longitude, respectively). I consider the person to have arrived when he is within 0.0005 of goal coordinates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;goal_latitude&lt;/TD&gt;&lt;TD&gt;goal_longitude&lt;/TD&gt;&lt;TD&gt;new_column&lt;/TD&gt;&lt;TD&gt;time1&lt;/TD&gt;&lt;TD&gt;latitude1&lt;/TD&gt;&lt;TD&gt;longitude1&lt;/TD&gt;&lt;TD&gt;time2&lt;/TD&gt;&lt;TD&gt;latitude1&lt;/TD&gt;&lt;TD&gt;longitude1&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;person1&lt;/TD&gt;&lt;TD&gt;55.7236&lt;/TD&gt;&lt;TD&gt;12.4472&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2023-08-03T19:55:18.000+02:00&lt;/TD&gt;&lt;TD&gt;55.7215&lt;/TD&gt;&lt;TD&gt;12.4422&lt;/TD&gt;&lt;TD&gt;2023-08-03T19:55:28.000+02:00&lt;/TD&gt;&lt;TD&gt;55.7215&lt;/TD&gt;&lt;TD&gt;12.4424&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;person2&lt;/TD&gt;&lt;TD&gt;55.7234&lt;/TD&gt;&lt;TD&gt;12.4418&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2023-08-03T19:55:01.000+02:00&lt;/TD&gt;&lt;TD&gt;55.7225&lt;/TD&gt;&lt;TD&gt;12.4368&lt;/TD&gt;&lt;TD&gt;2023-08-03T19:55:08.000+02:00&lt;/TD&gt;&lt;TD&gt;55.7226&lt;/TD&gt;&lt;TD&gt;12.4368&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;person3&lt;/TD&gt;&lt;TD&gt;55.7256&lt;/TD&gt;&lt;TD&gt;12.4435&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2023-08-03T19:55:37.000+02:00&lt;/TD&gt;&lt;TD&gt;55.7247&lt;/TD&gt;&lt;TD&gt;12.4389&lt;/TD&gt;&lt;TD&gt;2023-08-03T19:55:38.000+02:00&lt;/TD&gt;&lt;TD&gt;55.7247&lt;/TD&gt;&lt;TD&gt;12.4389&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can this be done in SAS Enterprise Guide?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have already tried with a very long CASE-statement:&lt;BR /&gt;CASE&lt;BR /&gt;WHEN (INPUT(t1.latitude1,8.))&amp;lt;(INPUT(t1.goal_latitude,8.) + 0.0005) AND (INPUT(t1.latitude1,8.))&amp;gt;((INPUT(t1.goal_longitude,8.) - 0.0005)) AND (INPUT(t1.longitude1,8.))&amp;lt;(INPUT(t1.goal_longitude,8.) + 0.0005) AND (INPUT(t1.longitude1,8.))&amp;gt;((INPUT(t1.longitude,8.) - 0.0005)) THEN (t1.time1)&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;ELSE 0&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I got this error message: "ERROR: Result of WHEN clause 2 is not the same data type as the preceding results."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;VictorK&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 08:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-Retrieve-value-from-a-column-if-a-certain-condition-is-met/m-p/888302#M43415</guid>
      <dc:creator>VictorK</dc:creator>
      <dc:date>2023-08-08T08:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help: Retrieve value from a column if a certain condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-Retrieve-value-from-a-column-if-a-certain-condition-is-met/m-p/888303#M43416</link>
      <description>&lt;P&gt;Please provide your sample data and the desired outcome using this sample data via a working SAS data step that creates such data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have a much better chance of anyone actually providing tested code if we don't have to spend time creating such sample SAS datasets prior to actually creating the code you're after.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 09:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-Retrieve-value-from-a-column-if-a-certain-condition-is-met/m-p/888303#M43416</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-08-08T09:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Help: Retrieve value from a column if a certain condition is met</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-Retrieve-value-from-a-column-if-a-certain-condition-is-met/m-p/888305#M43417</link>
      <description>&lt;P&gt;The dataset I'm working with is very large, but here are an example for one goal location.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 09:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-Retrieve-value-from-a-column-if-a-certain-condition-is-met/m-p/888305#M43417</guid>
      <dc:creator>VictorK</dc:creator>
      <dc:date>2023-08-08T09:24:51Z</dc:date>
    </item>
  </channel>
</rss>

