BookmarkSubscribeRSS Feed
A_B_C
Calcite | Level 5
I have to display a report like below. can any one help out how can i get it.

--------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------treatment=xxxx
---------------------------------------------------------------------(N=xx)
----------------------------------------------------------- Grade1 Grade2 Grade3
---------------------------------------------------------
SOC --------------- PT--------------------------- ------ n(%) --------- n(%) ---------- n(%)
---------------------------------------------------------------------------------------------------------------------

I am able to get everything except that treatment is not coming as shown in the above report and it should get repeated in every page along with N=xxx. And change in treatment should start in a new page.
Except the first and last lines, rest all dashed all lines represents blank spaces
Please help me..
8 REPLIES 8
Cynthia_sas
SAS Super FREQ
Hi:
You said you are able to get everything except the line with "treatment=xxxx" are you putting treatment=xxx in a TITLE statement??? Or is it a spanned header??? You say that a change in treatment should start a new page -- this sounds like something you'd accomplish with BY group processing -- are you using BY group processing in your code?? Or are you using PROC REPORT with the PAGE option? Or PROC TABULATE with the PAGE dimension?

Without seeing the code that you have (whether you're using PROC TABULATE, PROC REPORT)??? Knowing your destination of choice would also be useful: ODS RTF, ODS PDF, ODS HTML??

Can you share the code that you have used so far???

cynthia
Cynthia_sas
SAS Super FREQ
Also, this link
http://support.sas.com/forums/thread.jspa?messageID=27609毙

describes how to use the [pre] and [/pre] tags around your code and output in order to maintain indenting and spacing.

cynthia
A_B_C
Calcite | Level 5
I am using proc report with page option and able to get new page for each change in treatment. my output destination is SAS output window and RTF (both).

but I am unable to achieve the following
1. Treatment=xxxx and N=xxxx(will change according to treatment)should be displayed as columns headers


I tried many ways to get the treatment and N= as spanned headers but could not acheive it as per the format required.
here is the code
proc report data=adgrade nowd;
columns soc pt (treatment (patcnt grade1 grade2 grade3));
define soc / "SOC" width=20 flow;
define pt / "PT TERM" width=20 flow;
define treatment / group width=10;
define patcount / group width=10;
define grade1 / "Grade1" width=10;
define grade2 / "Grade2" width=10;
define grade3 / "Grade3" width=10;

break after treatment / page;

run;
Cynthia_sas
SAS Super FREQ
Hi,
The spanning header will be fixed text on every page. Another approach is to use BY group processing instead of the PAGE option and put the treatment and count into the by variable(s). That way, you could use #BYVAL in the SAS title statement on each page.

Cynthia
Cynthia_sas
SAS Super FREQ
Hi:
I have a few other comments/questions, now that I'm back at my computer.

-- You say that you want output in the LISTING window (output window) and RTF. However, some of your options (such as WIDTH and FLOW will only work in the LISTING window. They do not work in other ODS destinations.

-- I see that the usage of treatment and patcount is GROUP -- but what is the usage for SOC and PT??? Are they character or numeric variables (since you have specified FLOW, they must be character, but is their usage DISPLAY or ORDER or GROUP?? What about GRADE1, GRADE2, GRADE3??? The default usage for numeric variables is SUM.

-- you show this (nested parentheses in the COLUMN statement)
[pre]
columns soc pt (treatment (patcnt grade1 grade2 grade3));
[/pre]

usually this means that you have spanning headers, in this instance, what ARE the spanning headers that you have??? Can you show the actual COLUMN statement that you are using??

--are you seeing a message like this in your log:
[pre]
NOTE: Groups are not created because the usage of soc is DISPLAY. To avoid this note, change all GROUP variables to ORDER variables.
[/pre]

cynthia
A_B_C
Calcite | Level 5
Hi,
Thanks for your reply. please see my response and help me.
1. at present am trying to get the output for listing window, if it works then I will use rtf destination.
2.SOC and PT are character variables and Grade1 to Grade3 are numeric as they represent the frequency of each event. SOC and PT are group variables.
3. In order to get the Treatment=xxx and N=xxx as spanning headers I used column statement this way
columns soc pt (treatment (patcnt grade1 grade2 grade3));
but you said we can use only string constants as spanning headers . does it mean that we can't use variable values as spanning headers?
can we get the output by giving across option in define statement for treatment and patcnt variables? I tried with across option but unable to get as per my requirement. I Used by statement, but it donot give me the required format.
Any help is greatly appreciated.
Cynthia_sas
SAS Super FREQ
Hi:
You are correct -- using treatment as an ACROSS variable will cause each unique treatment to become a separate "column" on the report. However, you can get every ACROSS variable on a different page by using BY group processing on the same report.

You are also correct that if you use spanning headers in the COLUMN statement that the spanning header text is constant and would be the same on every page. You would have to take a different approach if you wanted the variable VALUES to be spanning headers.

I'm confused...which variable holds the N= value??? If SOC and PT are group variables, is this a summary report -- do you want all of some variable (like PATCNT) to be summarized to get N=?? If you want PATCNT to be summarized, then GROUP is the wrong usage. It would be useful to see what your data looks like in order to understand where the N= will come from.

I'm also curious about your use of the FLOW option -- usually, you use this option in the LISTING window to "wrap" text in a field -- since this option is ignored by ODS, you would use other techniques to cause wrapping. How big are SOC and PT in variable length??? This is another example of how it would be useful to see what your data looks like.

However, without having N= in the header, if you combined BY group processing with PROC REPORT and ACROSS, you can essentially get a separate page for every treatment. The program below uses SASHELP.SHOES -- Where you see "Boot" and "Slipper" would be the equivalent of where you want to see your TREATMENT variable -- PRODUCT in my code is both an ACROSS item and a BY variable. I have used the STORES variable where I think you might use PATCNT.

cynthia
[pre]
ods listing close;
ods rtf file='c:\temp\across_page.rtf';

options nobyline;
proc report data=shoes nowd;
title 'Proc Report BREAK after REGION gives SUBTOTAL on Region';
by product;
columns region subsidiary (product,(stores inventory returns sales));
define region /group "Region";
define subsidiary / group "Subsidiary";
define product / across ' ';
define stores / sum "Stores";
define inventory / sum "Inventory";
define returns / sum "Returns";
define sales / sum "Sales";

break after region / summarize;

run;
ods rtf close;
[/pre]
Ksharp
Super User
Guess that using 'line' statement can solve your probelm.Reference to previous posts.
The fastest way to solve your problem is to post some your origin data and whole SAS code.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 8 replies
  • 1109 views
  • 0 likes
  • 3 in conversation