<?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: Second place in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718097#M222162</link>
    <description>Your hometown is having a walk around the town square to raise money for&lt;BR /&gt;the library.&lt;BR /&gt;You have the following data: entry number, age group, and finishing time.&lt;BR /&gt;(Notice that there is more than one observation per line of data.)&lt;BR /&gt;&lt;BR /&gt;entry agegroup times&lt;BR /&gt;54 youth 35.5&lt;BR /&gt;21 adult 21.6&lt;BR /&gt;6 adult 25.8&lt;BR /&gt;13 senior 29.0&lt;BR /&gt;38 senior 40.3&lt;BR /&gt;19 youth 39.6&lt;BR /&gt;3 adult 19.0&lt;BR /&gt;25 youth 47.3&lt;BR /&gt;create a new variable for overall finishing place(ranking) and print the&lt;BR /&gt;results.&lt;BR /&gt;print the first (top finisher)and last finisher of each agegroup&lt;BR /&gt;in privious example create a new varible and assign the rank of each&lt;BR /&gt;walker in each agegroup and then choose just the first two top finnisher in&lt;BR /&gt;each agegroup&lt;BR /&gt;</description>
    <pubDate>Wed, 10 Feb 2021 02:21:47 GMT</pubDate>
    <dc:creator>akrishkumar</dc:creator>
    <dc:date>2021-02-10T02:21:47Z</dc:date>
    <item>
      <title>Second place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718044#M222137</link>
      <description>&lt;P&gt;How do i find second place for he below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data order2;&lt;BR /&gt;set order;&lt;BR /&gt;by agegroup;&lt;BR /&gt;if first.agegroup then&lt;BR /&gt;do;&lt;BR /&gt;group_place='First Place';*the top finisher of each agegroup;&lt;BR /&gt;end;&lt;BR /&gt;else if last.agegroup then&lt;BR /&gt;do;&lt;BR /&gt;group_place='Last Place';&lt;BR /&gt;end;&lt;BR /&gt;if first.agegroup or last.agegroup;*or if first.agegroup or last.agegroup then output order2 or if first.agegroup or last.agegroup then output;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 22:02:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718044#M222137</guid>
      <dc:creator>akrishkumar</dc:creator>
      <dc:date>2021-02-09T22:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: Second place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718046#M222138</link>
      <description>&lt;P&gt;Please provide some example data and what you expect for output.&lt;/P&gt;
&lt;P&gt;Define the conditions of what defines "second place".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data is sorted such that some other variable controls what order records are within the agegroup you can get "order" position with something like this:&lt;/P&gt;
&lt;PRE&gt;data order2;
   set order;
   by agegroup;
   retain order;
   if first.agegroup then
   do;
      group_place='First Place';*the top finisher of each agegroup;
      order=1;
   end;
   else order+1;
   if last.agegroup and not(first.agegroup) then
      group_place='Last Place';
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Currently your last line of code:&lt;BR /&gt;if first.agegroup or last.agegroup;&lt;/P&gt;
&lt;P&gt;would prevent output of anything resembling "second place".&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 22:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718046#M222138</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-09T22:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Second place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718047#M222139</link>
      <description>&lt;P&gt;Hi, since the BY grouping is done by a single variable, did you mean find the second observation?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 22:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718047#M222139</guid>
      <dc:creator>qoit</dc:creator>
      <dc:date>2021-02-09T22:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Second place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718073#M222150</link>
      <description>Yes please I have the first position and last for walkers...I want the&lt;BR /&gt;second position in the race.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Feb 2021 00:00:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718073#M222150</guid>
      <dc:creator>akrishkumar</dc:creator>
      <dc:date>2021-02-10T00:00:47Z</dc:date>
    </item>
    <item>
      <title>Re: Second place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718086#M222159</link>
      <description>&lt;P&gt;Hi, does the below help, I had to create a dummy dataset to ensure it works for you...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines truncover;
	length name $5. agegrp $18.;
	input name:$  agegrp &amp;amp; $ finishtime:time.;
	format finishtime time.;
	datalines;
john  between 15 and 30  00:01:12
jake  under 15           00:01:14
jason under 15           00:01:50
amy   between 15 and 30  00:00:59
jamie between 15 and 30  00:00:48
scott under 15           00:00:58
Cam   under 15           00:02:01
jacob under 15           00:01:45
jacob between 15 and 30  00:01:41
;
run;

proc sort data=have;
	by agegrp finishtime;
run;

data want;
	set have;
	by agegrp finishtime;
	retain freq;
	format place $20.;

	if first.agegrp then
		do;
			place = 'First Place';
			freq = 0;
		end;

	freq + 1;

	if freq = 2 then
		place = 'Second Place';

	if last.agegrp then
		place = 'Last Place';
run;



&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Feb 2021 01:06:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718086#M222159</guid>
      <dc:creator>qoit</dc:creator>
      <dc:date>2021-02-10T01:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Second place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718097#M222162</link>
      <description>Your hometown is having a walk around the town square to raise money for&lt;BR /&gt;the library.&lt;BR /&gt;You have the following data: entry number, age group, and finishing time.&lt;BR /&gt;(Notice that there is more than one observation per line of data.)&lt;BR /&gt;&lt;BR /&gt;entry agegroup times&lt;BR /&gt;54 youth 35.5&lt;BR /&gt;21 adult 21.6&lt;BR /&gt;6 adult 25.8&lt;BR /&gt;13 senior 29.0&lt;BR /&gt;38 senior 40.3&lt;BR /&gt;19 youth 39.6&lt;BR /&gt;3 adult 19.0&lt;BR /&gt;25 youth 47.3&lt;BR /&gt;create a new variable for overall finishing place(ranking) and print the&lt;BR /&gt;results.&lt;BR /&gt;print the first (top finisher)and last finisher of each agegroup&lt;BR /&gt;in privious example create a new varible and assign the rank of each&lt;BR /&gt;walker in each agegroup and then choose just the first two top finnisher in&lt;BR /&gt;each agegroup&lt;BR /&gt;</description>
      <pubDate>Wed, 10 Feb 2021 02:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718097#M222162</guid>
      <dc:creator>akrishkumar</dc:creator>
      <dc:date>2021-02-10T02:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Second place</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718129#M222180</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/368649"&gt;@akrishkumar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Your hometown is having a walk around the town square to raise money for&lt;BR /&gt;the library.&lt;BR /&gt;You have the following data: entry number, age group, and finishing time.&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;(Notice that there is more than one observation per line of data.)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;entry agegroup times&lt;BR /&gt;54 youth 35.5&lt;BR /&gt;21 adult 21.6&lt;BR /&gt;6 adult 25.8&lt;BR /&gt;13 senior 29.0&lt;BR /&gt;38 senior 40.3&lt;BR /&gt;19 youth 39.6&lt;BR /&gt;3 adult 19.0&lt;BR /&gt;25 youth 47.3&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;(1)&lt;/FONT&gt;&lt;/STRONG&gt; create a new variable for overall finishing place(ranking) and print the&lt;BR /&gt;results.&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;(2)&lt;/STRONG&gt;&lt;/FONT&gt; print the first (top finisher)and last finisher of each agegroup&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#FF6600"&gt;(3)&lt;/FONT&gt;&lt;/STRONG&gt; in privious example create a new varible and assign the rank of each&lt;BR /&gt;walker in each agegroup and then choose just the first two top finnisher in&lt;BR /&gt;each agegroup&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please post the data in usable form! I don't see multiple observations in the data.&lt;/P&gt;
&lt;P&gt;So you have three task, please show the code you have for the first two. Use the "insert code button", but before you do this: format the code.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 06:09:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Second-place/m-p/718129#M222180</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-02-10T06:09:23Z</dc:date>
    </item>
  </channel>
</rss>

