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!!
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.
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.
Maxim 1: Read the Documentation.
In particular, the TIES= option of the PROC RANK Statement
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.
