BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Aexor
Lapis Lazuli | Level 10

I coded below program .

 

Proc rank data=sashelp.cars;
var cylinders;
ranks ranking;
run;

 

but the ranking values comes as  

ranking

.

.

1

69.5

69.5

and so on

Please suggest what went wrong here.

Thanks!!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

What makes you think anything is wrong?

It did what you asked.

proc rank data=sashelp.cars out=ranks;
  var cylinders;
  ranks ranking;
run;

proc freq data=ranks;
  tables cylinders*ranking / list missprint;
run;
The FREQ Procedure

                                                 Cumulative    Cumulative
Cylinders    ranking    Frequency     Percent     Frequency      Percent
-------------------------------------------------------------------------
        .          .           2         .               .          .
        3          1           1        0.23             1         0.23
        4       69.5         136       31.92           137        32.16
        5        141           7        1.64           144        33.80
        6      239.5         190       44.60           334        78.40
        8        378          87       20.42           421        98.83
       10      422.5           2        0.47           423        99.30
       12        425           3        0.70           426       100.00

                          Frequency Missing = 2

So the lowest non-missing value is 3 and it is rank 1.  The next lowest value is 4 and it appears 136 times. So the average ranking for those 136 observations in 69.5, etc.

 

If you want it do do something else then tell it that by changing the options.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

What makes you think anything is wrong?

It did what you asked.

proc rank data=sashelp.cars out=ranks;
  var cylinders;
  ranks ranking;
run;

proc freq data=ranks;
  tables cylinders*ranking / list missprint;
run;
The FREQ Procedure

                                                 Cumulative    Cumulative
Cylinders    ranking    Frequency     Percent     Frequency      Percent
-------------------------------------------------------------------------
        .          .           2         .               .          .
        3          1           1        0.23             1         0.23
        4       69.5         136       31.92           137        32.16
        5        141           7        1.64           144        33.80
        6      239.5         190       44.60           334        78.40
        8        378          87       20.42           421        98.83
       10      422.5           2        0.47           423        99.30
       12        425           3        0.70           426       100.00

                          Frequency Missing = 2

So the lowest non-missing value is 3 and it is rank 1.  The next lowest value is 4 and it appears 136 times. So the average ranking for those 136 observations in 69.5, etc.

 

If you want it do do something else then tell it that by changing the options.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 859 views
  • 2 likes
  • 3 in conversation