BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
riya275
Obsidian | Level 7

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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).  

riya275
Obsidian | Level 7

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? 

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
riya275
Obsidian | Level 7

issue is proc freq wont work if done before. How do you suggest that would solve the problem?

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
Reeza
Super User

PROC TABULATE may be what you're looking for. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2098 views
  • 0 likes
  • 4 in conversation