BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ruth
Fluorite | Level 6

Hi,

To explain what I want, please let me show the simple code:

proc sort data=work.city;

  by descending gdp;

run;

Then I want to create a variable in the data work.city, which indicates the group that the case belongs to based on its gdp level. Group 1 has the largest gdp, and group 10 has the lowest gdp. Each group has equal number of cases.

How can do it?

Cheers.

Ruth.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Couldn't you just use proc rank .. the data doesn't even have to be sorted.  Just specify the number of groups you want. e.g.,

data city;

  input city gdp;

  cards;

1 10

2 9

3 8

4 7

5 6

6 5

7 4

8 3

9 2

10 12

11 13

12 14

;

proc rank data=city groups=4 out=want;

  var gdp;

  ranks gdprank;

run;

View solution in original post

1 REPLY 1
art297
Opal | Level 21

Couldn't you just use proc rank .. the data doesn't even have to be sorted.  Just specify the number of groups you want. e.g.,

data city;

  input city gdp;

  cards;

1 10

2 9

3 8

4 7

5 6

6 5

7 4

8 3

9 2

10 12

11 13

12 14

;

proc rank data=city groups=4 out=want;

  var gdp;

  ranks gdprank;

run;

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 Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 489 views
  • 0 likes
  • 2 in conversation