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

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Proc tabulate?

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

11-14-2017 04:30 PM

I have a number of variables showing time in minutes, each with many observations. I need to show each of the variables as a percentage of the total.I think I need to use proc tabulate but am new to SAS. Can someone help?

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

Posted in reply to Nini

11-14-2017 04:53 PM

I don't think PROC TABULATE will do what you want with multiple variables.

I think you'll need multiple steps, likely a PROC MEANS and a FREQ or a DATA STEP.

Either way, for more assistance please post sample data and your expected output.

Don't post images as sample data, that would mean we have to type it out

Nini wrote:

I have a number of variables showing time in minutes, each with many observations. I need to show each of the variables as a percentage of the total.I think I need to use proc tabulate but am new to SAS. Can someone help?

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

Posted in reply to Nini

11-14-2017 04:53 PM

Can you post a sample of your dataset and in what format you want the report ?

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

Posted in reply to Nini

11-15-2017 03:21 AM

Thanks all,

here is a sample of my data

Outdoor Leisure Team Domestic Walk Cycle Total

0 0 15 20 0 0 35

0 10 0 10 5 0 25

35 0 50 0 15 0 85

I just want to show how each of the variables contributes to the total something like below

Outdoor 25%

Leisure 10%

Team 15%

Domestic 5%

Walk 15%

Cycle 30%

Total 100%

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

Posted in reply to Nini

11-15-2017 08:49 AM

It is very easy for IML .

```
data have;
input Outdoor Leisure Team Domestic Walk Cycle Total ;
cards;
0 0 15 20 0 0 35
0 10 0 10 5 0 25
35 0 50 0 15 0 85
;
run;
proc iml;
use have;
read all var _num_ into x[c=vname];
close;
ratio=t(x[+,]/sum(x[,ncol(x)]));
print (t(vname)) ratio[f=percent8.2];
quit;
```