BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
NKormanik
Barite | Level 11

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

11 REPLIES 11
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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>.

Reeza
Super User

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

 

 

Cynthia_sas
SAS Super FREQ

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

 

NKormanik
Barite | Level 11

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

 

 

Cynthia_sas
SAS Super FREQ

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;
NKormanik
Barite | Level 11

"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....

 

NKormanik
Barite | Level 11

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

 

Cynthia_sas
SAS Super FREQ
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
NKormanik
Barite | Level 11

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

 

Ya did good, sweetheart.

 

Reeza
Super User

@NicholasKormanik wrote:

 

Ya did good, sweetheart.

 


Patronizing much? 

NKormanik
Barite | Level 11

Just showing appreciation.

 

Reeza, you do good, too.

 

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

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 11 replies
  • 1922 views
  • 6 likes
  • 4 in conversation