I am trying to create a report using proc report where in I have grouped by a variable named probability and inside the groupped variable is another variable Account_name which is a character variable. I want to the frequency of this variable for each group of probability
eg-
probability Accounts
1 3
0.9 4
0.8 6
and so on, but i am not able to do that because it displays all the account_Names inside each probability rather than the freuency/count of the column
what i am getting is
probability accounts
1 LG
max
LF
0.9 GH
PL
and so on
following is the code I used-
proc report data= c1.o;
columns probability____ Account_Name Total_Media_Value Forecasted_Budget;
define probability____ / group order descending 'Probability';
define Account_Name/ n 'Accounts';
define Total_Media_Value /sum 'Total_Budget';
define Forecasted_Budget/ computed 'Forecasted Budget';
compute Forecasted_Budget;
Forecasted_Budget= (Total_Media_Value.sum)*(probability____);
endcomp;
run;
in the define Account_Name line i have used display and analysis as well but no use
i get the error
ERROR: Account_Name is an ANALYSIS variable but not numeric.
PROC SUMMARY will give you frequencies in a dataset, it can sum the Total_Media_Value, and so on. If you need to compute percentages from those frequencies this is also done easily in a SAS data step. I find it much easier to do manipulations in a SAS data step than getting the math correct in PROC REPORT.
Do a proc freq or means before getting to the proc report. Report is a reporting procedure, not a freq/means procedure (even though it can do some basic stuff).
Is the issue that the column is of character format?Because for numerical columns it can calculate a lot of statistics even percentiles.And how do i combine the freq table with the report table?
@RW9 wrote:
Do a proc freq or means before getting to the proc report. Report is a reporting procedure, not a freq/means procedure (even though it can do some basic stuff).
I agree with this. Getting the data computed properly before you run PROC REPORT will make your life sooooooo much simpler.
issue is proc freq wont work if done before. How do you suggest that would solve the problem?
PROC SUMMARY will give you frequencies in a dataset, it can sum the Total_Media_Value, and so on. If you need to compute percentages from those frequencies this is also done easily in a SAS data step. I find it much easier to do manipulations in a SAS data step than getting the math correct in PROC REPORT.
PROC TABULATE may be what you're looking for.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.