BookmarkSubscribeRSS Feed
Amber_Nicole94
Obsidian | Level 7

Using SAS EG 7.1 and trying to make the variables repeat values in a summary table. It is currently only showing the first value.

 

Example:

What I am getting now

OriginDestinationCost
New YorkFlorida200
 Colorado638
 Kentucky194

 

 

 

What I want

OriginDestinationCost
New YorkFlorida200
New YorkColorado638
New YorkKentucky194
5 REPLIES 5
ballardw
Super User

You should describe how you are doing that summary. There a number of different ways to summarize data and we need a starting point. If you are using tasks you may be missing an option.

 

And are you creating a data set or a report?

Amber_Nicole94
Obsidian | Level 7

I have my starting point whch is a data set that I have created and manipulated. Then I have selected Tasks > Describe > Summary Tables.

 

Data Tab:

Analysis Variable = Cost

Classification Variables = Origin, Destination

 

Summary Tables Tab:

Placed them where I want them.

 

Run.

mkeintz
PROC Star

And what is the sas program code generating these results?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Amber_Nicole94
Obsidian | Level 7
TITLE;
TITLE1 "Summary Tables";
FOOTNOTE;
FOOTNOTE1 "Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), TIMEAMPM12.))";
/* -------------------------------------------------------------------
   Code generated by SAS Task

   Generated on: Wednesday, September 27, 2017 at 3:40:58 PM
   By task: Summary Tables (2)

   Input Data: SASApp:WORK.QUERY_FOR_APPEND_TABLE_0001
   Server:  SASApp
   ------------------------------------------------------------------- */


/* -------------------------------------------------------------------
   Run the tabulate procedure
   ------------------------------------------------------------------- */
PROC TABULATE
DATA=WORK.QUERY_FOR_APPEND_TABLE_0001
	
	;
	
	VAR Units "COST"n;
	CLASS Origin /	ORDER=UNFORMATTED MISSING;
	CLASS Destination /	ORDER=UNFORMATTED MISSING MLF;
	TABLE /* Row Dimension */
'Origin'n*(
    Destination 
  ALL={LABEL="Total (ALL)"}),
/* Column Dimension */
COST*
  Sum;
	;

RUN;
/* -------------------------------------------------------------------
   End of task code
   ------------------------------------------------------------------- */
RUN; QUIT;
TITLE; FOOTNOTE;
Cynthia_sas
SAS Super FREQ

Hi:

  This is something you might want to try with the List Report task instead of Summary Tables task. Or else learn PROC REPORT code. This is easier to do with PROC REPORT than with TABULATE.

 

  As an example -- the top table is PROC TABULATE on a subset of SASHELP.SHOES and the bottom table is the PROC REPORT TABLE showing the region on each row, as you want.

 

tab_vs_report.png

 

Here's the code:

title; footnote;

PROC TABULATE DATA=sashelp.shoes;
    where product in ('Boot' 'Sandal' 'Slipper') and
	      region in ('Asia' 'Canada');
	VAR sales;
	CLASS region product	 ;
	TABLE /* Row Dimension */
    region*(product ALL={LABEL="Total (ALL)"}),
    sales* Sum;
RUN;

proc report data=sashelp.shoes;
    where product in ('Boot' 'Sandal' 'Slipper') and
	      region in ('Asia' 'Canada');
  column region show_region product sales;
  define region / group noprint;
  define show_region/ computed 'Region' style(column)=Header;
  define product / group style(column)=Header;
  define sales / sum f=dollar14.;
  break after region / summarize style=Header;
  compute before region;
    hold = region;
  endcomp;
  compute show_region / character length=30;
    show_region = hold;
  endcomp;
  compute after region;
     show_region = "Total (ALL)";
  endcomp;
run;

 

  Hope this helps,

cynthia

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
  • 5 replies
  • 1161 views
  • 0 likes
  • 4 in conversation