Hello programmers,
I have a dataset that i want to output using Proc report to print it but i ran into difficulties.
I want my final report in the format:
Variables (Tn) Sample Size (N) Mean(P) Standard Deviation (std) Count of Yeses (N x P) Percentages (Count / N x 100)
My codes are attached and any input would be appreciated.
data me;
input tc Tn $ n p std;
datalines;
1 Angina 15050 0.2031 0.40234
2 Heartburn 15050 0.2297 0.42065
3 Sleepiness 15042 0.1735 0.3787
4 Exercise 15058 0.23 0.42083
5 Palpitation 14991 0.1512 0.35828
6 Any 15020 0.5214 0.49956
7 BMI 15063 25.3549 4.30121
; run;
proc report data= me headline headskip;
title1 "Descriptive Statistics For Study Population";
column tn N Mean std count ;
define Tn / group width=20 'Variables';
define N / group width=10 'Sample Size';
define P / group format=6.2 width=10 'Mean';
define std/group format=6.2 width=10 'Standard Deviation';
define count/group format=6.2 width=5 'Count of Yeses (N*P)';
define perctn/group format=6.2 width=5 'Percentages %(Count/N X 100)';
compute Count ;
count = N*P;
endcomp;
compute perctn ;
perctn = count/N;
endcomp ;
run;
Hi:
Here's how I changed the DATA step:
And here's how I changed the PROC REPORT step.
Your usage of GROUP did not makes sense, so I changed most of the usages other than COMPUTED and ORDER to simple DISPLAY, which is OK if you don't need any grand totals at the bottom of the report.
Cynthia
Attached is the error message.
Is there no way i can compute Count and perctn and then include them in my final report table?
define count/computed format= ... ;
In the future, we prefer SAS logs to appear as text, pasted into the window that appears when you click on the {i} icon.
Thanks Paige.
It worked but it gave me the attached output.
Three questions that i want to ask.
1. Many of my variable names were cut off. What could be the cause?
2. I do not want the count of yeses and percentages for the BMI variable. How do i specially treat it (remove) them.
3. Is there a way i can use Options or ODS statement to put my proc report output in a nice font?
Hi:
1. Many of my variable names were cut off. What could be the cause? >> You need to specify a LENGTH statement where you read in the data. The default length of character variables is 8.<<
2. I do not want the count of yeses and percentages for the BMI variable. How do i specially treat it (remove) them.
>> You can code an IF statement in your COMPUTE block to test for the value which you want to have computed differently. There are many different examples of previous forum postings of using IF statements in a COMPUTE block. <<
3. Is there a way i can use Options or ODS statement to put my proc report output in a nice font?
>>What do you consider a "nice" font? Try a different style using the STYLE= option. What is your destination of choice? <<
Cynthia
Please can you share a template?
I've done an if statement to no avail.
A link would be helpful too.
Hi:
Here's how I changed the DATA step:
And here's how I changed the PROC REPORT step.
Your usage of GROUP did not makes sense, so I changed most of the usages other than COMPUTED and ORDER to simple DISPLAY, which is OK if you don't need any grand totals at the bottom of the report.
Cynthia
Thanks very much!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.