Programming the statistical procedures from SAS

Help with SAS Code

Reply
New Contributor
Posts: 2

Help with SAS Code

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.

PROC Star
Posts: 7,416

Help with SAS Code

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.

New Contributor
Posts: 2

Help with SAS Code

Ok, thanks!

Super User
Posts: 9,753

Help with SAS Code

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

Ask a Question
Discussion stats
  • 3 replies
  • 130 views
  • 0 likes
  • 3 in conversation