BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10

I didnot get output plese give solution 

Kurt_Bremser
Super User

Write the data step to create Total.

Write a PROC RANK step, according to the documentation.

Sort the result.

 

It's that easy.

 

Listen, Anand: I want you to LEARN something, and develop the ability to solve problems on your own. You will not learn ANYTHING if all you do is copy the code we give you, without understanding what's going on. Learning by doing is the best method by far, so DO!

BrahmanandaRao
Lapis Lazuli | Level 10
proc import datafile='/home/u35263349/My_Folder/Olympics.xlsx'
out=ds
dbms=xlsx;
run;

data ds1;
set ds;
Total=sum(gold ,silver, bronze);
proc print;
run;

proc rank data=ds1 out=ranking  descending ties=dense;
var Total ;
ranks  total_by_ranks ;
run;

OLYMPICS OUTPUT;

Team Gold Silver Bronze Total Total_by_Rank
Japan 10 3 5 18 3
United States of America 9 8 8 25 1
People's Republic of China 9 5 7 21 2
ROC 7 7 4 18 3
Great Britain 4 5 4 13 5
Republic of Korea 3 2 5 10 7
Australia 3 1 5 9 8
Canada 2 3 3 8 9
France 2 2 3 7 10
Germany 2 0 3 5 12
Kosovo 2 0 0 2 22
Italy 1 5 6 12 6
Chinese Taipei 1 2 3 6 11
Brazil 1 2 2 5 12
Switzerland 1 2 2 5 12
Slovenia 1 1 1 3 15
Serbia 1 1 1 3 15
Hungary 1 1 0 2 22
Tunisia 1 1 0 2 22
Austria 1 0 1 2 22
Croatia 1 0 1 2 22
Estonia 1 0 1 2 22
Bermuda 1 0 0 1 36
Ecuador 1 0 0 1 36
Hong Kong, China 1 0 0 1 36
Islamic Republic of Iran 1 0 0 1 36
Norway 1 0 0 1 36
Philippines 1 0 0 1 36
Thailand 1 0 0 1 36
Uzbekistan 1 0 0 1 36
Netherlands 0 3 0 3 15
Spain 0 2 1 3 15
Georgia 0 2 0 2 22
South Africa 0 2 0 2 22
Mongolia 0 1 2 3 15
Belgium 0 1 1 2 22
Czech Republic 0 1 1 2 22
Indonesia 0 1 1 2 22
Bulgaria 0 1 0 1 36
Colombia 0 1 0 1 36
Denmark 0 1 0 1 36
India 0 1 0 1 36
Jordan 0 1 0 1 36
North Macedonia 0 1 0 1 36
Romania 0 1 0 1 36
Turkmenistan 0 1 0 1 36
Kazakhstan 0 0 3 3 15
Ukraine 0 0 3 3 15
Egypt 0 0 2 2 22
Mexico 0 0 2 2 22
Turkey 0 0 2 2 22
Côte d'Ivoire 0 0 1 1 36
Cuba 0 0 1 1 36
Israel 0 0 1 1 36
Kuwait 0 0 1 1 36
New Zealand 0 0 1 1 36

 

BUT TOTAL_BY_RANK difference from GREAT Britain  

please correct where i was wrong

 

MYCODE_OUTPUT

 

Obs Team Gold Silver Bronze Total total_by_ranks
1 Japan 10 3 5 18 3
2 United States of America 9 8 8 25 1
3 People's Republic of China 9 5 7 21 2
4 ROC 7 7 4 18 3
5 Great Britain 4 5 4 13 4
6 Republic of Korea 3 2 5 10 6
7 Australia 3 1 5 9 7
8 Canada 2 3 3 8 8
9 France 2 2 3 7 9
10 Germany 2 0 3 5 11
11 Kosovo 2 0 0 2 13
12 Italy 1 5 6 12 5
13 Chinese Taipei 1 2 3 6 10
14 Brazil 1 2 2 5 11
15 Switzerland 1 2 2 5 11
16 Slovenia 1 1 1 3 12
17 Serbia 1 1 1 3 12
18 Hungary 1 1 0 2 13
19 Tunisia 1 1 0 2 13
20 Austria 1 0 1 2 13
21 Croatia 1 0 1 2 13
22 Estonia 1 0 1 2 13
23 Bermuda 1 0 0 1 14
24 Ecuador 1 0 0 1 14
25 Hong Kong, China 1 0 0 1 14
26 Islamic Republic of Iran 1 0 0 1 14
27 Norway 1 0 0 1 14
28 Philippines 1 0 0 1 14
29 Thailand 1 0 0 1 14
30 Uzbekistan 1 0 0 1 14
31 Netherlands 0 3 0 3 12
32 Spain 0 2 1 3 12
33 Georgia 0 2 0 2 13
34 South Africa 0 2 0 2 13
35 Mongolia 0 1 2 3 12
36 Belgium 0 1 1 2 13
37 Czech Republic 0 1 1 2 13
38 Indonesia 0 1 1 2 13
39 Bulgaria 0 1 0 1 14
40 Colombia 0 1 0 1 14
41 Denmark 0 1 0 1 14
42 India 0 1 0 1 14
43 Jordan 0 1 0 1 14
44 North Macedonia 0 1 0 1 14
45 Romania 0 1 0 1 14
46 Turkmenistan 0 1 0 1 14
47 Kazakhstan 0 0 3 3 12
48 Ukraine 0 0 3 3 12
49 Egypt 0 0 2 2 13
50 Mexico 0 0 2 2 13
51 Turkey 0 0 2 2 13
52 Côte d'Ivoire 0 0 1 1 14
53 Cuba 0 0 1 1 14
54 Israel 0 0 1 1 14
55 Kuwait 0 0 1 1 14
56 New Zealand 0 0 1 1 14
 
ballardw
Super User

See what happens if you try different values for the TIES=option in Proc Rank.

 

From the documentation:

DENSE

computes scores and ranks by treating tied values as a single-order statistic. For the default method, ranks are consecutive integers that begin with the number one and end with the number of unique, nonmissing values of the variable that is being ranked. Tied values are assigned the same rank.

 

 

 

 

 

BrahmanandaRao
Lapis Lazuli | Level 10

Hi 

KurtBremser

THANK YOU VERY MUCH FOR YOUR  SUPPORT 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 20 replies
  • 1764 views
  • 2 likes
  • 4 in conversation