BookmarkSubscribeRSS Feed
v307086
Calcite | Level 5

Hello,

I am new to SAS and while I was learning I was using proc report for sashelp.class, and then fetching the output in an rtf format to see the output but in reality I got a simple tabular format and didn't get expected results.

Here's the code:

title "ABC school";
title2 "Students report";
footnote "This is a sample report.Don't rely on it";
ods rtf file="/home/u62925501/MyFolder/sample.rtf";
proc report data=sashelp.class (obs =10) nowd headline headskip split='*' out= ds1;
columns ("Student Class data"("Details" name sex) ("Measures" age height weight));
define sex/group;
break after sex/summarize;
run;
ods rtf close;

 

 

Here's the output coming in rtf file:

v307086_0-1674409562135.png

 

 

Expected output is:(note it is just a sample image)

v307086_1-1674409561975.png

 

 

 Thanks in advance

7 REPLIES 7
PaigeMiller
Diamond | Level 26

Your expectations are wrong. PROC REPORT gave you exactly what you asked for.

 

If you want something like the text output shown, you'd have to write code to get that, or perhaps use the %TABLEN macro.

--
Paige Miller
sbxkoenk
SAS Super FREQ

SAS ODA = SAS OnDemand for Academics (ODA).
For the rest ... , no clue what you are talking about ☹️.

Please elaborate !

 

Koen

v307086
Calcite | Level 5

Hello,

I am new to SAS and while I was learning I was using proc report for sashelp.class, and then fetching the output in an rtf format to see the output but in reality I got a simple tabular format and didn't get expected results.

Here's the code:

title "ABC school";
title2 "Students report";
footnote "This is a sample report.Don't rely on it";
ods rtf file="/home/u62925501/MyFolder/sample.rtf";
proc report data=sashelp.class (obs =10) nowd headline headskip split='*' out= ds1;
columns ("Student Class data"("Details" name sex) ("Measures" age height weight));
define sex/group;
break after sex/summarize;
run;
ods rtf close;

 

 

Here's the output coming in rtf file:

v307086_0-1674409020728.png

 

Expected output is:(note it is just a sample image)

v307086_1-1674409395740.png

 

 Thanks in advance

PaigeMiller
Diamond | Level 26

Hello @v307086 , don't post the same question twice, and don't change the topic of a thread in the middle. Your PROC REPORT question should be discussed in your other thread at https://communities.sas.com/t5/SAS-Programming/proc-report-in-SAS-ODA/td-p/855012/jump-to/first-unre...

--
Paige Miller
Cynthia_sas
SAS Super FREQ
Hi:
Your screen shot of desired results is the type of report typically called a demographic report. There is not any SAS procedure that will generate that type of report for you by default. You have to do more manipulation of the summarized data in order to generate the type of report you show. For example, your XX (XX%) for the values for the Active vs the Placebo is usually the concatenation of 2 numeric variables (N and PCTN) in order to make a character string that can be displayed under each major column. Typically, to get the results for GENDER, you run PROC FREQ for each of your groups (ACTIVE/PLACEBO) and then for your AGE values, you run PROC MEANS. Generally, you need to post process the data from both of these procedures to get the data in a form that's ready for PROC REPORT. There are several macro programs floating around that do it. I have several examples using PROC REPORT with some helper variables in my Creating Complex Reports paper and Lisa Fine has some examples of this type of report in her book on using PROC REPORT and I'm sure I remember several PharmaSUG papers that had different ways to use PROC REPORT or the DATA step to generate this type of report.
Cynthia
PaigeMiller
Diamond | Level 26

In SAS Studio, you can call up any table to view it, and leave it viewable for as long as you want (in other words until you close it).

Step 1: Go to Libraries on the left.

Step 2: Expand "My Libraries".

Step 3: Expand the library of interest (often the WORK library).

Step 4: double-click on the data set of interest.

 

When you next run code, the data set you just opened remains open, however "My Libraries" collapses and you have to go through steps 2 through 4 again to get to that library. I do find this incredibly annoying and a major drawback of SAS Studio, making programming much more time consuming, but it is possible.

--
Paige Miller

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
  • 1032 views
  • 0 likes
  • 4 in conversation