BookmarkSubscribeRSS Feed
Emma_at_SAS
Lapis Lazuli | Level 10

I am exporting the results from PROC SURVEYFREQ by ODS OUTPUT and clean my data for a report. I copied the example tables below. I have 2 questions please:

1- How may I merge the headings for the 95% CI in the ODS OUTPUT data?

2- Using ODS WORD to create the report, each table appears on a separate page. How may I make a continuous report without breaking the page after each table?

Thanks!

 

The output from PROC SURVEYFREQ:

Table of AGE_GROUP

AGE_GROUP

Weighted
Frequency

Percent

95% Confidence Limits
for Percent

10-15 years

1260

50.9

48.3

53.5

16-20 years

1216

49.1

46.5

51.7

Total

2476

100.0

 

 

 

ODS OUTPUT sorted:

Age group

Frequency

Percent

Lower_95_percent_CI

Upper_95_percent_CI

10-15 years

1260

50.9

48.3

53.5

16-20 years

1216

49.1

46.5

51.7

8 REPLIES 8
Reeza
Super User
Look at the STARTPAGE options in ODS WORD to control when a new page starts.

Are you using PROC REPORT to print the first table? That would be the easiest way to have that span, though I'd consider pre-processing the field so your confidence interval shows as below and then use a single column via PROC PRINT.

(48.3, 53.5)

Or consider selectively piping the output directly to word rather than using the intermediary tables. Which doesn't work if you're re-ordering data and/or changing things massively. Rough example below:

ods excel file='.....';
ods select summarytable;
proc surveyFREQ data=....;

run;
ods excel close;
Emma_at_SAS
Lapis Lazuli | Level 10

Thank you, Reeza. I will check the STARTPAGE option for page breaks.

I used PROC PRINT to print the data I saved with PROC OUTPUT. What is the advantage of PROC REPORT over PROC PRINT?

 

I keep your suggested example in mind for future use. For this project, I need to reorder the columns and eliminate the total row. So, I think this example does not work.

 

Thanks.

Reeza
Super User
PROC REPORT has more options for formatting and styling your columns and can do more types of calculations. PRINT is primarily used to just display information as is, typically without manipulating the structure.

REPORT is PRINT on steroids and is incredibly powerful for creating almost any type of customized tables. If the column headers are always the same then getting spanning headers via PROC REPORT is trivial. I think you could trick it in PRINT by modifying the template or style to remove the line but REPORT is worth learning if you're going to be creating automated reports.
Emma_at_SAS
Lapis Lazuli | Level 10

Thank you, Reeza. Yes, I am creating automated reports and based on your explanation it sounds PROC REPORT would be a better option for me. I will switch to PROC REPORT. 

 

Thanks

Reeza
Super User
https://communities.sas.com/t5/SAS-Communities-Library/Spanning-Headers-in-PROC-REPORT/ta-p/476002

https://support.sas.com/resources/papers/proceedings12/242-2012.pdf

I highly recommend Art Carpenters book on PROC REPORT as a reference. It'll save you a lot of time in programming/googling.
Emma_at_SAS
Lapis Lazuli | Level 10

Thanks for the resources, Reeza.

I tried STARTPAGE="NO" but my small tables are still on separate pages. I think that controls columns of a table not separate tables! Any suggestions? Maybe I am doing that wrong!

Thanks

Reeza
Super User
Show your code please. It controls tables, definitely not columns on a table.

Emma_at_SAS
Lapis Lazuli | Level 10

Thanks, Reeza. Yes, you are right. I am not introducing the STARTPAGE option correctly. STARTPAGE=NO asks for quotations and STARTPAGE="NO" does not recognize the option.

 

ODS WORD FILE="C:\path\test.docx" options(STARTPAGE="NO");

 

Thanks

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 8 replies
  • 1407 views
  • 3 likes
  • 2 in conversation