- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi, have get stuck in a thing with SAS. I should compare 4 different companys income during a period in three country in different county.In the table i only want to pick the company with highest total income for each county in every country.
the table look something like this:
Country.........County........Company.......Income
Country1.......Countyx......Compay1.......45000
......................................Company2.....45600
......................................Company3.....30566
......................................Company4.....38000
.
.
.
.
.
.
Country3.....Countyz......Company1......360000
....................................Company2......500000
....................................Company3......32100
....................................Company4......200000
That i want is to only get the bold lines in a table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can sort the tables in descending income order then, in a data step, include a by desceding income and include an if first.income statement. Or, you could use proc sql and use a where income eq max(income( statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ok, thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
nodupkey option of proc sort will keep the first obs.
So if you have already sort your data as you want. then you will get the max obs.
data class;
set sashelp.class;
run;
proc sort data=class ;
by sex decending weight;
run;
proc sort data=class out=cl nodupkey ;
by sex;
run;
Ksharp