<?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 Data for highest variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317231#M69420</link>
    <description>&lt;P&gt;I am trying to get the maximum no of passengers in greyhound and megabus&amp;nbsp;&amp;amp; abc routes to different cities .&amp;nbsp;&lt;/P&gt;&lt;P&gt;If i take one city Washington-WA and there are many buses going in different years to WA with different no of passenger(WAP).I have 20,000 of data set , just giving a short form,As my code is not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bus &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WAP &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Year&lt;/P&gt;&lt;P&gt;Greyhound &amp;nbsp; 4220 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;Megabus &amp;nbsp; &amp;nbsp; &amp;nbsp;3200 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15 00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2000&lt;/P&gt;&lt;P&gt;Greyhound &amp;nbsp; 4200 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2001&lt;/P&gt;&lt;P&gt;Megabus &amp;nbsp; &amp;nbsp; &amp;nbsp;3290 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2001&lt;/P&gt;&lt;P&gt;abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1598 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2001&lt;/P&gt;&lt;P&gt;Greyhound &amp;nbsp; 5200 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2002&lt;/P&gt;&lt;P&gt;Megabus &amp;nbsp; &amp;nbsp; &amp;nbsp;3250 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2002&lt;/P&gt;&lt;P&gt;abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2002&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to have one observation for the Bus variable with max passengers for the Year 2001.&lt;/P&gt;&lt;P&gt;I want to create a variable that represents the no of passengers per Bus for Year 2001 and which Bus. If anybody can help , and also can help me change that code to macro so that i can use any number of city,&amp;nbsp;as i have 16 cities data. I will be very thanksful if anybody help me in getting the code right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc means nolabels data=WAP Max;&lt;BR /&gt;class Bus Year;&lt;BR /&gt;output out=maxp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=maxp;&lt;BR /&gt;where _stat_= MAX Year=2001;&lt;BR /&gt;var Bus Year WAP;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2016 07:57:17 GMT</pubDate>
    <dc:creator>afs</dc:creator>
    <dc:date>2016-12-07T07:57:17Z</dc:date>
    <item>
      <title>Data for highest variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317231#M69420</link>
      <description>&lt;P&gt;I am trying to get the maximum no of passengers in greyhound and megabus&amp;nbsp;&amp;amp; abc routes to different cities .&amp;nbsp;&lt;/P&gt;&lt;P&gt;If i take one city Washington-WA and there are many buses going in different years to WA with different no of passenger(WAP).I have 20,000 of data set , just giving a short form,As my code is not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bus &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; WAP &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Year&lt;/P&gt;&lt;P&gt;Greyhound &amp;nbsp; 4220 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;Megabus &amp;nbsp; &amp;nbsp; &amp;nbsp;3200 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000&lt;/P&gt;&lt;P&gt;abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 15 00 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2000&lt;/P&gt;&lt;P&gt;Greyhound &amp;nbsp; 4200 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2001&lt;/P&gt;&lt;P&gt;Megabus &amp;nbsp; &amp;nbsp; &amp;nbsp;3290 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2001&lt;/P&gt;&lt;P&gt;abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1598 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2001&lt;/P&gt;&lt;P&gt;Greyhound &amp;nbsp; 5200 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2002&lt;/P&gt;&lt;P&gt;Megabus &amp;nbsp; &amp;nbsp; &amp;nbsp;3250 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2002&lt;/P&gt;&lt;P&gt;abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2000 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2002&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to have one observation for the Bus variable with max passengers for the Year 2001.&lt;/P&gt;&lt;P&gt;I want to create a variable that represents the no of passengers per Bus for Year 2001 and which Bus. If anybody can help , and also can help me change that code to macro so that i can use any number of city,&amp;nbsp;as i have 16 cities data. I will be very thanksful if anybody help me in getting the code right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc means nolabels data=WAP Max;&lt;BR /&gt;class Bus Year;&lt;BR /&gt;output out=maxp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=maxp;&lt;BR /&gt;where _stat_= MAX Year=2001;&lt;BR /&gt;var Bus Year WAP;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 07:57:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317231#M69420</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-12-07T07:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: Data for highest variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317232#M69421</link>
      <description>&lt;P&gt;I am having a bit of trouble understanding this, could you post what your desired output looks like? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 07:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317232#M69421</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2016-12-07T07:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: Data for highest variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317237#M69423</link>
      <description>1) i want to have data set result showing for the year 2001 which Bus had maximum no of passengers.&lt;BR /&gt;&lt;BR /&gt;Can i get the above result please. Then i can run and ask again to discuss what i need.As data i have got is messy and i am trying to sort it. With your help i can get at least maximum no of people travelling in 2001 by which Bus.&lt;BR /&gt;thanks&lt;BR /&gt;</description>
      <pubDate>Wed, 07 Dec 2016 08:17:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317237#M69423</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-12-07T08:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Data for highest variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317239#M69424</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input bus :$20. wap year;
cards;
Greyhound   4220           2000
Megabus      3200           2000
abc                1500          2000
Greyhound   4200           2001
Megabus      3290           2001
abc                1598           2001
Greyhound   5200           2002
Megabus      3250           2002
abc                2000           2002
;
run;

proc sql;
create table want as
select bus, wap
from have
where year = 2001
having wap = max(wap)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2016 08:30:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317239#M69424</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-07T08:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Data for highest variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317242#M69426</link>
      <description>Can i please get in SAS as i have to make macros also then . I hope i am not bothering you much.Thanks</description>
      <pubDate>Wed, 07 Dec 2016 08:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317242#M69426</guid>
      <dc:creator>afs</dc:creator>
      <dc:date>2016-12-07T08:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Data for highest variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317243#M69427</link>
      <description>&lt;P&gt;This IS valid Base SAS code, believe me. Just run it.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 09:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317243#M69427</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-07T09:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: Data for highest variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317244#M69428</link>
      <description>&lt;P&gt;And if you tell me what needs to be made dynamic, I can at least give you hints how to do it.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 09:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317244#M69428</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-07T09:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Data for highest variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317250#M69429</link>
      <description>&lt;P&gt;To get a good answer to your question, follow some general tips on posting:&lt;/P&gt;
&lt;P&gt;- Post test data, in the form of a datastep&lt;/P&gt;
&lt;P&gt;- Post example output you require&lt;/P&gt;
&lt;P&gt;- Try to keep requirements to exactly what the question is about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2016 09:26:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317250#M69429</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-12-07T09:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Data for highest variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317259#M69438</link>
      <description>&lt;PRE&gt;
For the legitimate sas data step code , could like:

proc sort data=have out=temp;
 by bus year wap;
run;
data want;
 set temp;
 by bus year;
 if last.year;
run;




&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2016 10:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317259#M69438</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-07T10:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Data for highest variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317272#M69446</link>
      <description>&lt;P&gt;You have not yet responded with&amp;nbsp;an actual example of the result you wish to generate, so we are all trying to read your mind.&amp;nbsp; Here is my guess.&amp;nbsp; It uses the PROC MEANS that you have chosen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notes&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You will only get&amp;nbsp;the maximum WITHIN class.&amp;nbsp; So use only year as a class variable, to get max within year.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;You want to use BUS as the id variable for the maximum passengers - so examine the MAXID clause in the output statement.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Because the OUTPUT statement is being used to give names to statistics (i.e. maxwap) and id variables (maxwapbus), it doesn't generate one obs per stat per class.&amp;nbsp; It generates one obs per class, with several variables (one per stat).&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;if there are two bus lines with maximum passengers for a given year, you will only get the name of the first one encountered in data set wap.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data=wap nway noprint;
  class year;
  var  wap;
  output out=want maxid(wap(bus))=maxwapbus  max=maxwap;
run;

proc print data=want;
  var year maxwapbus maxwap;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Dec 2016 12:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-for-highest-variable/m-p/317272#M69446</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2016-12-07T12:04:46Z</dc:date>
    </item>
  </channel>
</rss>

