Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- Programming
- /
- Creating a subgroup and finding the deciles of the remaining observati...

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

🔒 This topic is **solved** and **locked**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 09-01-2020 11:31 AM
(590 views)

Dear All:

My data is as follows

VarA IDA 4 1 6 2 2 3 1 4 10 5 22 6 2 7 1 8 85 9 I want to create a subgroup when VARA = 1 and VarA = 2, name the subgroup as Rank = 0 and then find find the deciles for the remaining values.

Thanks

Ramdy

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

proc rank data=have groups=10;

where vara not in (1,2);

var varA;

ranks rank_varA;

run;

where vara not in (1,2);

var varA;

ranks rank_varA;

run;

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

VARA = 1 and VarA = 2, you mean OR I assume?

proc univariate data=have ;

where vara in (1,2);

var ida;

output out=deciles pctlpre = P_ pctlpts=0 to 100 by 10;

run;

https://stats.idre.ucla.edu/sas/faq/how-do-i-obtain-percentiles-not-automatically-calculated/

run;

proc univariate data=have ;

where vara in (1,2);

var ida;

output out=deciles pctlpre = P_ pctlpts=0 to 100 by 10;

run;

https://stats.idre.ucla.edu/sas/faq/how-do-i-obtain-percentiles-not-automatically-calculated/

run;

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I want to create a subgroup when VARA = 1 and VarA = 2, name the subgroup as Rank = 0 and then find find the deciles for the remaining values.

I'm really struggling to decipher this into something I could program. When you talk about "the remaining values", are these the values that are *not* in RANK=0? Or are they the values of VARA=1 and VARA=2? Why the name RANK=0, this seems to imply something, but I can't figure it out. Is there also a RANK=1?

Can you show us the desired output from this small example?

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Paige -- Here is the intuition. I have a column with a series of values. I want to group them into deciles, but not include values of 1 or 2 into the decile grouping, keeping them as a separate group.

so if the values of VarA are

VARA Rank_A

1 -1

3 1

6 2

8 3

9 4

14 5

2 -1

66 6

VARA = 1 OR VARA =2 always get a rank of say ( -1 or 0 -- it does not matter) and the ranks are determined on the remaining values. I hope that I am clearer -- I apologize for any confusion.

Randy

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

proc rank data=have groups=10;

where vara not in (1,2);

var varA;

ranks rank_varA;

run;

where vara not in (1,2);

var varA;

ranks rank_varA;

run;

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

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.