BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
3 REPLIES 3
deleted_user
Not applicable
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
deleted_user
Not applicable
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
deleted_user
Not applicable
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 672 views
  • 0 likes
  • 1 in conversation