BookmarkSubscribeRSS Feed
delarge
Calcite | Level 5

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.

3 REPLIES 3
art297
Opal | Level 21

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.

delarge
Calcite | Level 5

Ok, thanks!

Ksharp
Super User

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1192 views
  • 0 likes
  • 3 in conversation