BookmarkSubscribeRSS Feed
Haris
Lapis Lazuli | Level 10

Looking for a way to insert a row above each section of a table.  For example, a table can have Races and Age groups like this:

Variable  Value

White      50 

Black      60

Asian      10

Other      20

<20        15

20-30      7

30-50      8

50-75     25

>75       60

In the report, I'd like to display this:

Variable  Value

    R A C E

White      50 

Black      60

Asian      10

Other      20

  A G E   G R O U P

<20        15

20-30      7

30-50      8

50-75     25

>75       60

Appreciate any suggestions.

Haris    

7 REPLIES 7
ballardw
Super User

How are you generating the tables currently? Code example?

Haris
Lapis Lazuli | Level 10

Tables are all generated outside of PROC REPORT using SQL, FREQ, MEANS, etc.  It's for the demographics table of a manuscripts with predictors as rows, groups as columns, Ns, p-values, etc.  At the moment, I am only interested in making the output prettier and removing the manual step of adding the section headings.  I don't think what I am looking for can be made entirely in PROC REPORT or any one procedure for that matter.

Thanks,

Haris

ballardw
Super User

Proc Tabulate actually does similar to what you want.

Take a look at the output from:

proc tabulate data=sashelp.class;

   class sex;

   class age;

   table sex age,

         n=''*f=f4.0;

run;

But without some details of what your data looks like and what you have tried, we can't get much further.

Summarized data can be displayed using FILE Print and Put statements in a data step if you need something other than "simple" tables, but again we need to know what the data looks like.

Fugue
Quartz | Level 8

Without more specifics it's hard to say what approach to follow. Adding a "space" between the header/column names and the rest of the table is doable -- all depends on the approach(es) you are using.

Haris
Lapis Lazuli | Level 10

And thought I was as clear as it gets Smiley Happy

Here's the code for full table as well as a PROC REPORT I am currently using--it's a standard table 1 from any medical journal:

data have;

  input Variable $;

  N1 = ranuni(0); N2 = ranuni(0);

  Group1 = put(ranuni(0),8.2); Group2 = put(ranuni(0),8.2);

  PVal= ranuni(0);

  cards;

Var1

Var2

Var3

Var4

AgeGr1

AgeGr2

AgeGr3

Race1

Race2

Race3

Region1

Region2

Region3

Region4

;

run;

proc report data=have;

  column ('Predictor' Variable)

  ('Number of Patients' N1 N2)

  ('Mean/STD' Group1 Group2)

  ('p-value' PVal);

  define Variable / display '';

  define N1 / display center;

  define N2 / display center;

  define Group1 / display center;

  define Group2 / display center;

  define Pval / display center '';

run;

Output is the table below (for some reason the (headers are cut off but they don't matter).  At the moment I am typing the bold category headings manually and would like to automate it.  Tried COMPUTE BEFORE but got lost.

        

Other Pt Variables
A0.99456480.4985552  0.32  0.120.6276928
B0.08050720.6616233  0.05  0.230.4454616
C0.95245910.6282662  0.03  0.38 0.304287
D0.57376790.1142044  0.57  0.490.7099973
Age Group
AgeGr10.95182480.2908635  0.35  0.890.6725817
AgeGr2 0.5073290.5758729  0.84  0.090.6611321
AgeGr30.51575270.4067989  0.98  0.400.4416961
Race
Race10.10755040.9987347  0.96  0.250.5914531
Race20.96695180.6722821  0.88  0.480.4796646
Race30.81725020.8970209  0.42  0.070.6066189
Geographical Region
Region10.61317520.7856588  0.40  0.520.0752222
Region20.98143830.9802798  0.48  0.520.6117008
Region3 0.1767670.2434878  0.82  0.660.6990772
Region40.87582620.9445898  0.72  0.540.8402694
Cynthia_sas
SAS Super FREQ

Hi,

This paper has several examples of this type of demographic report.

http://www2.sas.com/proceedings/forum2008/173-2008.pdf

In addition if you search PharmaSUG papers at lexjansen.com, you should find more examples.

cynthia

BrunoMueller
SAS Super FREQ

Hi

You can use the COMPUTE BEFORE with a LINE statement to do something like this, see sample code below. For the grouping you need a new variable which is not shown in the report but needed to have "break lines".

Proc Format;
 
value $category
   
"VAR" = "Other PT Variables"
   
"AGEGR" = "Age Group"
   
"RACE" = "Race"
   
"REGION" = "Geographical Region"
  ;
run;
data have;
  input Variable $;
  category = put(upcase(compress(variable, "0123456789")), $category.);
  N1 = ranuni(0);
  N2 = ranuni(0);
  Group1 = put(ranuni(0),8.2);
  Group2 = put(ranuni(0),8.2);
  PVal= ranuni(0);
  cards;
Var1
Var2
Var3
Var4
AgeGr1
AgeGr2
AgeGr3
Race1
Race2
Race3
Region1
Region2
Region3
Region4
;
run;

proc report data=have;
  column category ('Predictor' Variable)

    (
'Number of Patients' N1 N2)

    (
'Mean/STD' Group1 Group2)

    (
'p-value' PVal)
;
  define category / group order=data noprint;
 
define Variable / display '';
 
define N1 / display center;
 
define N2 / display center;
 
define Group1 / display center;
 
define Group2 / display center;
 
define Pval / display center '';

 
compute before category / style={just=left background=bibg};
    l = length(category);
   
line category $varying254. l;
  endcomp;
run;

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
  • 7 replies
  • 1340 views
  • 6 likes
  • 5 in conversation