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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1211 views
  • 0 likes
  • 3 in conversation