BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data cars(keep= make type msrp cnt Header1 Date1 Report_Date1 h1 h2 h3 h4 h5);

length Header1 $25.;

set sashelp.cars;

Date1="1jun2019"d;

Report_Date1=put(Date1,yymmdd10.);

if make in ('Acura','Audi','Buick','BMW','Cadillac');

if make='Acura' then h1=1;

if make='Audi' then h2=1;

if make='Buick' then h3=1;

if make='BMW' then h4=1;

if make='Cadillac' then h5=1;

if make in('BMA','Buick') then Header1='Eastern';

if make in('Audi') then Header1='Central';

if make in('Acura','Cadillac') then Header1='Western';

cnt=1;

run;

proc tabulate =cars;

class Report_Date1 Header1 /order=data ;

var h1 h2 h3 h4 h5 cnt;

table report_date1 = '' All ,

( h1=''*sum='Acura' *f=comma9.

h2=''*sum='Audi'*f=comma9.

h3=''*sum='Buick'*f=comma9.

h4=''*sum='BMW'*f=comma9.

H5=''*sum='Cadillac'*f=comma9.

cnt=''*sum='Row Totals'*f=comma9.)

/box='Summary';

run;

It produces a display based on the sequence of h1,h2 etc

1.Is there a way to assign a header on top of the columns based on the Header1 description here (ie Eastern, Central, Western)??

 

2.Secondly is there a way to not show the ALL totals at the bottom

 

\

  Eastern Central Western  
Summary BMW Buick Audi Aura Cadillac Row Totals
6/1/2019 20 9 19 7 8 63
All 20 9 19 7 8 63

2 REPLIES 2
Cynthia_sas
Diamond | Level 26

Hi:
It's not clear to me whether you want the "header1" and the h1, h2, h3 etc, or just the Header 1 values in the header. In fact, it looks like H1, H2, H3, etc are just being used instead of the N statistic (N is for Count). So I'm not sure WHAT your code is intending to do.

As for your #2, you have ALL in the row dimension (right after report_date1) -- you get rid of the ALL at the bottom by removing the ALL from the TABLE statement.
Cynthia

 

Here's something that may be close to what you want, just using a format and N and changing your initial program a bit:

use_n_tab.png

Astounding
PROC Star

From your post, it looks like you have questions about how your program is working now.  Let's address both desires.

 

The program uses order=data.  So if you want to change the order of the column headings, change the order of the data.  For example:

 

data cars2;

set cars (where=(header1='Eastern'))

cars (where=(header1='Central'))

cars (where=(header1='Western'));

run;

 

Then use CARS2 in PROC TABULATE instead of CARS.

 

To get rid of the SUMMARY line, take it out of PROC TABULATE.  You are requesting it by adding the word ALL:

 

table report_date1 = '' All ,

 

Change that to:

 

table report_date1 = '',

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 645 views
  • 0 likes
  • 3 in conversation