turn on suggestions

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

Showing results for

Find a Community

Topic Options

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-16-2017 03:04 PM - edited 03-16-2017 03:06 PM

Hi,

I have a dataset called A:

Count | Percent

0 | 0.05

2 | 0.15

5 | 0.20

... .....

How can I obtain a dataset called B, where Cumulative Percentage for Count = 5 is the Percentage for Count <= 5:

(p(Count = 0) + p(Count = 2) + p(Count = 5) = 0.05 + 0.15 + 0.2 = 0.4)

Count | Perenct | Cumulative Percent

0 | 0.05 | 0.05

2 | 0.15 | 0.20

5 | 0.20 | 0.40

... ... ...

Thanks!

Accepted Solutions

Solution

03-16-2017
03:25 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Crubal

03-16-2017 03:18 PM

Are you using IML?

My assumption is you're looking to calculate the cumulative value?

If so, something as simple as:

```
retain cum_percent;
cum_percent = sum(cum_percent, percent);
```

All Replies

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Crubal

03-16-2017 03:18 PM

Use the CUSUM function:

```
proc iml;
percent = {0.05, 0.15, 0.2, 0.4, 0.2};
cusum = cusum(percent);
print percent cusum;
```

Solution

03-16-2017
03:25 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Crubal

03-16-2017 03:18 PM

Are you using IML?

My assumption is you're looking to calculate the cumulative value?

If so, something as simple as:

```
retain cum_percent;
cum_percent = sum(cum_percent, percent);
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

03-16-2017 03:25 PM

Hi,

Any kind of procedure if works would be great! And I just tried yours in a data step, and got what I have. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Crubal

03-16-2017 03:29 PM

I'm not sure how you're calculating those numbers in the first place, but if using proc freq/means/tabulate you should be able to calculate the cumulative directly.