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

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; 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  Here's how I changed the DATA step:

length.png

 

And here's how I changed the PROC REPORT step.

report_changes.png

 

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

View solution in original post

7 REPLIES 7
ChuksManuel
Pyrite | Level 9

Attached is the error message.

 

Is there no way i can compute Count and perctn and then include them in my final report table?Count.JPG

PaigeMiller
Diamond | Level 26
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.

--
Paige Miller
ChuksManuel
Pyrite | Level 9

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?

des.JPG

Cynthia_sas
SAS Super FREQ

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

ChuksManuel
Pyrite | Level 9

Please can you share a template?

I've done an if statement to no avail.

A link would be helpful too.

 

Cynthia_sas
SAS Super FREQ

Hi:

  Here's how I changed the DATA step:

length.png

 

And here's how I changed the PROC REPORT step.

report_changes.png

 

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

ChuksManuel
Pyrite | Level 9

Thanks very much!

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

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
  • 7 replies
  • 1023 views
  • 5 likes
  • 3 in conversation