|
Bob Lan wrote:
> Dear all,
>
> What I want is something similar to the table below but a rtf output.
> Sex and name are in the same column. But name is indented. Do you know
> how to do this in a rtf output?
>
> Thanks for your help,
>
> Bob
>
> ------------------------------
> |Variable | N | % |
> |--------------+------+------|
> |Female | | |
> | Alice | 1| 5.3|
> | Barbara | 1| 5.3|
> | Carol | 1| 5.3|
> | Jane | 1| 5.3|
> | Janet | 1| 5.3|
> | Joyce | 1| 5.3|
> | Judy | 1| 5.3|
> | Louise | 1| 5.3|
> | Mary | 1| 5.3|
> |Male | | |
> | Alfred | 1| 5.3|
> | Henry | 1| 5.3|
> | James | 1| 5.3|
> | Jeffrey | 1| 5.3|
> | John | 1| 5.3|
> | Philip | 1| 5.3|
> | Robert | 1| 5.3|
> | Ronald | 1| 5.3|
> | Thomas | 1| 5.3|
> | William | 1| 5.3|
> ------------------------------
Unfortunately, class hierarchies in SAS output is displayed using columns
and not indented values of a single multi-contexted column.
In order to index levels of a class, you would need to use tabulate to
create an output table with computed cell values and use a data step with
some by group processing. In this case it is pretty easy because the
hierarchy sex*name. The more variables in the hierarchy, the more by group
ifs you need in your data step.
The issue of class hierarchy presentation is one SAS should really address.
The columnar only format makes some output from SAS look rather clunky in
comparison to other products (such as TPL Tables by www.qqqsoft.com, see
http://www.qqqsoft.com/html/products/samples_html_2.html)
Other techniques might include proc report with special compute sections.
Example
-----
ods listing close;
ods output table=myTabulation;
proc tabulate data=sashelp.class;
class sex name;
table sex*name,sex*(N pctn);
run;
ods rtf file='c:\temp\junk1.rtf';
options missing = ' ';
data _null_;
set myTabulation;
where _type_ = '11';
by sex;
length level $20;
file print ods = (variables=(level _N _pctn));
if first.sex then do;
level = sex;
_n = .;
_pctn = .;
put _ods_;
end;
level = repeat ('A0'x,1) || name; * here is your indentation;
_n = n;
_pctn = pctn_00;
put _ods_;
run;
ods _all_ close;
-----
Richard A. DeVenezia
http://www.devenezia.com
|