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
- /
- SAS Procedures
- /
- 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
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-27-2011 09:09 AM

Hi All,

I have three ciolumns in a SAS dataset 'All' :- Source, Converting users, Non Converting users.

In the Source, I have codes - 'A','B','C','D'

Could you suggest how I can find the Percentage of Converting users which is defined as: (Converting users / Total users)for each source.

Kind Regards

Kriti

I have three ciolumns in a SAS dataset 'All' :- Source, Converting users, Non Converting users.

In the Source, I have codes - 'A','B','C','D'

Could you suggest how I can find the Percentage of Converting users which is defined as: (Converting users / Total users)for each source.

Kind Regards

Kriti

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

Posted in reply to deleted_user

01-27-2011 09:54 AM

Hello,

my solution is based on proc report which has the advantage of fields calculation:

[pre]

proc report data=sashelp.class nowd box;

column sex height weight total height_proc total_last ;

define sex / group width=12;

define height / analysis noprint;

define weight / analysis noprint;

define height_proc / computed format=percent7.1 width=12;

define total / computed noprint ;

define total_last / computed format=comma8. width=12;

compute total;

total=height.sum+weight.sum;

endcomp;

compute height_proc;

height_proc=height.sum/total;

endcomp;

compute total_last;

total_last=total;

endcomp;

compute after;

line "Total number of Users:" +5 total_last comma8.;

endcomp;

run;

[/pre]

Marius

my solution is based on proc report which has the advantage of fields calculation:

[pre]

proc report data=sashelp.class nowd box;

column sex height weight total height_proc total_last ;

define sex / group width=12;

define height / analysis noprint;

define weight / analysis noprint;

define height_proc / computed format=percent7.1 width=12;

define total / computed noprint ;

define total_last / computed format=comma8. width=12;

compute total;

total=height.sum+weight.sum;

endcomp;

compute height_proc;

height_proc=height.sum/total;

endcomp;

compute total_last;

total_last=total;

endcomp;

compute after;

line "Total number of Users:" +5 total_last comma8.;

endcomp;

run;

[/pre]

Marius

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

Posted in reply to deleted_user

01-27-2011 10:52 AM

Hi Marius,

Many thanks for the suggestion. I tried this code on the data that I have but when I try to find the Percentages there are blanks.

Suppose I have the SAS data set 'All':

Source Converted Users Non Converted Users Total

A 100 567 667

A 200 328 528

A 150 938 1088

B 140 843 983

B 143 327 470

C 327 732 1059

D 323 634 957

C 133 526

D 268 828

I use the code:-

proc report data=all nowd box;

column Source Percent;

define Source / group width=12;

compute Percent;

Percent=(Converting_users/Total)*100;

endcomp;

run;

The code works well but does not ouput the desired Percent for each Source.

Kind Regards

Kriti

Many thanks for the suggestion. I tried this code on the data that I have but when I try to find the Percentages there are blanks.

Suppose I have the SAS data set 'All':

Source Converted Users Non Converted Users Total

A 100 567 667

A 200 328 528

A 150 938 1088

B 140 843 983

B 143 327 470

C 327 732 1059

D 323 634 957

C 133 526

D 268 828

I use the code:-

proc report data=all nowd box;

column Source Percent;

define Source / group width=12;

compute Percent;

Percent=(Converting_users/Total)*100;

endcomp;

run;

The code works well but does not ouput the desired Percent for each Source.

Kind Regards

Kriti

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

Posted in reply to deleted_user

01-27-2011 11:24 AM

hello,

your proc report has no information about Converting_users and Total, this is the reason why you have blanks for percentages. you should add those data set variables in the column statement (**to the left of percent**) ,define them as analysis variables. I suppose your total variable is calculated for all observations and has no missing, as appears on the last 2 lines of your post, otherwise I suggest to calculate it in the report as shown in my previous post:

[pre]

proc report nowd box;

column Source Converting_users Total Percent;

define Source / group width=12;

define Converting_users / analysis noprint width=12;

define Total / analysis noprint width=12;

define percent / computed;

compute Percent;

percent=(Converting_users.sum/Total.sum)*100;

endcomp;

run;

[/pre]

Marius

your proc report has no information about Converting_users and Total, this is the reason why you have blanks for percentages. you should add those data set variables in the column statement (

[pre]

proc report nowd box;

column Source Converting_users Total Percent;

define Source / group width=12;

define Converting_users / analysis noprint width=12;

define Total / analysis noprint width=12;

define percent / computed;

compute Percent;

percent=(Converting_users.sum/Total.sum)*100;

endcomp;

run;

[/pre]

Marius