Help using Base SAS procedures

Show additional information in tabular cells

Accepted Solution Solved
Reply
Regular Contributor
Posts: 212
Accepted Solution

Show additional information in tabular cells

Please see image below.  The inner cells contain frequencies.

 

I would like to ADDITIONALLY include in each cell values for a third variable, and even a fourth variable.

 

For instance, in addition to the 3231, I would like to see the average score, from, say, Slope_5040x, and, say, Slope_5050x.

 

 

Proc Freq.png

 

My hunch is, Proc Freq is not the appropriate procedure to do what I am asking for.

 

Help and advice greatly appreciated.

 

Nicholas Kormanik

 

 


Accepted Solutions
Solution
‎08-25-2016 08:17 PM
SAS Super FREQ
Posts: 8,743

Re: Show additional information in tabular cells

Hi:

  My guess is that if you can use PROC REPORT directly or you can "pre-process" your data in a DATA step. But whichever way, you have to insert the ESCAPECHAR command sequence for "newline" into the string you build. 

cynthia

 

Consider these examples.

stack_variables_forum.png

 

View solution in original post


All Replies
Super User
Super User
Posts: 7,401

Re: Show additional information in tabular cells

Any information on what that is?  Test data in the form of a datastep and what the output should look like help.  What is all the _date and _number things about?  If you have data like then then your best bet is to normalise it, i.e. don't have dates going across but have them in a column going down, and then use by <group>;  You can then transpose the results.  Proc means can do mean values and counts, and by <groups>.

Super User
Posts: 17,829

Re: Show additional information in tabular cells

You probably want Proc tabulate but it won't be the same cell. 

 

 

Solution
‎08-25-2016 08:17 PM
SAS Super FREQ
Posts: 8,743

Re: Show additional information in tabular cells

Hi:

  My guess is that if you can use PROC REPORT directly or you can "pre-process" your data in a DATA step. But whichever way, you have to insert the ESCAPECHAR command sequence for "newline" into the string you build. 

cynthia

 

Consider these examples.

stack_variables_forum.png

 

Regular Contributor
Posts: 212

Re: Show additional information in tabular cells

Thanks Cynthia.  Looks like Proc Report is perhaps the best way to show more information in table form.  So, a new proc to study.

 

Even having a DIFFERENT table would be nice, showing information on another variable.

 

What I mean is, each cell in the above table shows the frequency, or number of observations in that cell.

 

Well, what is the mean result for those observations?  Let's say, average score on some given test.  How did that particular group score?

 

Would be nice to see that number in table form, too.  Maybe in a separate table.  So I can hold the two tables side by side.  And easily make comparisons.

 

Ideally it would be terrific to be able to place multiple measures/numbers into each cell. Perhaps with a legend at the bottom saying what the numbers represent.

 

Hopefully Proc Report can do this without too much fuss.

 

Nicholas

 

 

SAS Super FREQ
Posts: 8,743

Re: Show additional information in tabular cells

Hi:

  PROC REPORT won't put 2 tables side by side unless you use COLUMNS=2 for an ODS DESTINATION that supports the COLUMNS= option (RTF and PDF). What you want to do depends on  your destination to some extent.

 

  PROC REPORT can calculate the same summary statistics that TABULATE can, except for KURTOSIS and SKEWNESS. But what if you wanted mean and pvalue and CSS or some other statistic from some other procedure. As long as you can create 1 dataset with all the information you want, then you can stack the data in the cell however you want, given that you use NEWLINE and ESCAPECHAR to insert the "line feed" into the appropriate place in the cell.

 

  For an example (well 3 examples, really) of a standard demographic report, please refer to #1 -- 2 examples on page 9, and #8 - pg 17 in this paper http://www2.sas.com/proceedings/forum2008/173-2008.pdf  and in #7-pg 24  in this paper http://support.sas.com/resources/papers/proceedings16/SAS5762-2016.pdf

 

  To put 2 tables side by side, like this, you only need COLUMNS=2 -- here's a PDF example:

pdf_table.png

from the code below. Except for the style, the RTF output looks the same.

 

cynthia

 

options orientation=landscape topmargin=.5in bottommargin=.5in
             leftmargin=.5in rightmargin=.5in nodate nonumber;
    
ods pdf file='c:\temp\twocol.pdf' columns=2;
ods rtf file='c:\temp\twocol.rtf' columns=2;

proc report data=sashelp.class;
  column age sex,(n height height=htpctn);
  define age / group;
  define sex / across;
  define n / 'Count';
  define height / mean 'Avg' f=6.2;
  define htpctn / pctn 'Pct' f=percent9.2;
  rbreak after / summarize;
run;
   
proc report data=sashelp.class;
  column age sex,(height height=htmax height=htmed);
  define age / group;
  define sex / across;
  define height / min 'Min';
  define htmax / max 'Max';
  define htmed / Median 'Median';
  rbreak after / summarize;
run;
ods _all_ close;
Regular Contributor
Posts: 212

Re: Show additional information in tabular cells

"PROC REPORT won't put 2 tables side by side unless you use COLUMNS=2 for an ODS DESTINATION that supports the COLUMNS= option."

 

Cynthia, I wasn't saying to print on the same page.  I can print on two separate pages, no prob.

 

Just give me, please, SAS, two tables....

 

Regular Contributor
Posts: 212

Re: Show additional information in tabular cells

Nice coding, Cynthia.  I'll try to use it.

 

SAS Super FREQ
Posts: 8,743

Re: Show additional information in tabular cells

To get multiple tables, from PROC REPORT, either use BY group processing to get a separate table for every BY group or use the PAGE option on the BREAK after.

Otherwise, I am not sure what you mean when you plead for "just...two tables".

cynthia
Regular Contributor
Posts: 212

Re: Show additional information in tabular cells

Cynthia, just as you've shown above.  That's what I want.

 

Ya did good, sweetheart.

 

Super User
Posts: 17,829

Re: Show additional information in tabular cells


NicholasKormanik wrote:

 

Ya did good, sweetheart.

 


Patronizing much? 

Regular Contributor
Posts: 212

Re: Show additional information in tabular cells

Just showing appreciation.

 

Reeza, you do good, too.

 

Love the help here.  You're all the best!

 

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 11 replies
  • 350 views
  • 6 likes
  • 4 in conversation