12-07-2016 02:57 AM
I am trying to get the maximum no of passengers in greyhound and megabus & abc routes to different cities .
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.
Bus WAP Year
Greyhound 4220 2000
Megabus 3200 2000
abc 15 00 2000
Greyhound 4200 2001
Megabus 3290 2001
abc 1598 2001
Greyhound 5200 2002
Megabus 3250 2002
abc 2000 2002
How to have one observation for the Bus variable with max passengers for the Year 2001.
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, as i have 16 cities data. I will be very thanksful if anybody help me in getting the code right.
proc means nolabels data=WAP Max;
class Bus Year;
proc print data=maxp;
where _stat_= MAX Year=2001;
var Bus Year WAP;
12-07-2016 03:17 AM
12-07-2016 03:30 AM
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;
12-07-2016 04:01 AM
12-07-2016 04:02 AM
12-07-2016 04:26 AM
To get a good answer to your question, follow some general tips on posting:
- Post test data, in the form of a datastep
- Post example output you require
- Try to keep requirements to exactly what the question is about
12-07-2016 07:04 AM
You have not yet responded with an actual example of the result you wish to generate, so we are all trying to read your mind. Here is my guess. It uses the PROC MEANS that you have chosen.
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;