Help using Base SAS procedures

PROC TABULATE

Reply
N/A
Posts: 0

PROC TABULATE

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
N/A
Posts: 0

Re: PROC TABULATE

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
N/A
Posts: 0

Re: PROC TABULATE

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
N/A
Posts: 0

Re: PROC TABULATE

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
Ask a Question
Discussion stats
  • 3 replies
  • 141 views
  • 0 likes
  • 1 in conversation