<?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: SAS Scenario in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/447065#M112239</link>
    <description>&lt;P&gt;NO. I have no time to do this. Hash Table is a big topic to talk.&lt;/P&gt;</description>
    <pubDate>Tue, 20 Mar 2018 12:23:20 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-03-20T12:23:20Z</dc:date>
    <item>
      <title>SAS Scenario</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446760#M112145</link>
      <description>&lt;DIV&gt;&lt;DIV&gt;Hi&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Could you please help me for the same? I do have data like below sample data.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Data Flight;&lt;/DIV&gt;&lt;DIV&gt;input id source $ destination$;&lt;/DIV&gt;&lt;DIV&gt;datalines;&lt;/DIV&gt;&lt;DIV&gt;1 Delhi&amp;nbsp; Bangalore&lt;/DIV&gt;&lt;DIV&gt;2 Delhi&amp;nbsp; Goa&lt;/DIV&gt;&lt;DIV&gt;1 Bangalore&amp;nbsp; Goa&lt;/DIV&gt;&lt;DIV&gt;2 Goa Bangalore&lt;/DIV&gt;&lt;DIV&gt;1 Goa Delhi&lt;/DIV&gt;&lt;DIV&gt;;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;Questions&lt;/DIV&gt;&lt;DIV&gt;===========&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;1. Output data set Should be RoundTrip&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;id Roundtrip&lt;/DIV&gt;&lt;DIV&gt;1 Yes&lt;/DIV&gt;&lt;DIV&gt;2 No&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;2 What is last&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;destination&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of&amp;nbsp; person which is not completed Round trip.( For example id 2 is not completed the round trip and his last destination is&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Bangalore)&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 19 Mar 2018 13:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446760#M112145</guid>
      <dc:creator>neha_gupta</dc:creator>
      <dc:date>2018-03-19T13:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scenario</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446783#M112159</link>
      <description>&lt;P&gt;What is the definition of a "round trip" in terms of the data content? Are you looking for a data set as a result or a report for people to read? You also mention "person" but it is not obvious from your data that ID is a person.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What have you tried so far? What result were you not able to get?&lt;/P&gt;
&lt;P&gt;Since this looks like course homework you'll get a lot more from any answer if you have at least attempted something. You may have been close but missed a thing or two and we'll gladly help with that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One might also say that without dates it is hard to determine if something is truly a round trip as we don't know in what order any of the flights may have occurred and if there are 3 years between flights it would not normally be considered a "round trip".&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446783#M112159</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-19T14:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scenario</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446795#M112165</link>
      <description>&lt;P&gt;If there was only one to one match, that would be easy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Flight;
input id source $ destination$;
datalines;
1 Delhi  Bangalore
2 Delhi  Goa
1 Bangalore  Goa
2 Goa Bangalore
1 Goa Delhi
;
data want;
 if _n_=1 then do;
    if 0 then set flight;
    declare hash h(dataset:'flight');
    h.definekey('id','source');
    h.definedata('destination');
    h.definedone();
 end;
set flight;
temp=source;
do while(h.find(key:id,key:temp)=0);
 temp=destination;
 if source=temp then leave;
end;
 Roundtrip=ifn(source=destination,1,0);
drop temp;
run;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446795#M112165</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-03-19T14:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scenario</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446800#M112168</link>
      <description>&lt;P&gt;Sort and data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Flight;
input id source :$20. destination :$20.;
datalines;
1 Delhi  Bangalore
2 Delhi  Goa
1 Bangalore  Goa
2 Goa Bangalore
1 Goa Delhi
;
run;

proc sort data=flight;
by id;
run;

data want;
set flight;
by id;
retain depart;
length depart $20;
if first.id then depart = source;
if last.id
then do;
  if depart = destination then last_destination = 'Roundtrip';
  else last_destination = destination;
  output;
end;
keep id Last_destination;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note I added formats in the first step, so that the default length of 8 is not used.&lt;/P&gt;
&lt;P&gt;I assume your real dataset will contain dates and times, so you should use those in the sort to make sure a correct order is achieved.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446800#M112168</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-19T14:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scenario</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446809#M112173</link>
      <description>Yes,Its working fine. Could you please explain me?</description>
      <pubDate>Mon, 19 Mar 2018 14:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446809#M112173</guid>
      <dc:creator>neha_gupta</dc:creator>
      <dc:date>2018-03-19T14:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scenario</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446819#M112177</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code is also working fine. Thank you so much.Its easy to understand me.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 15:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/446819#M112177</guid>
      <dc:creator>neha_gupta</dc:creator>
      <dc:date>2018-03-19T15:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scenario</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/447065#M112239</link>
      <description>&lt;P&gt;NO. I have no time to do this. Hash Table is a big topic to talk.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 12:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scenario/m-p/447065#M112239</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-03-20T12:23:20Z</dc:date>
    </item>
  </channel>
</rss>

