BookmarkSubscribeRSS Feed
LindaH1120
Fluorite | Level 6

Have an issue that I can’t see to resolve.  I am using an across variable.  I have two columns which are sub totals of the across value.  I have a subtotal for FEMALEs and another subtotal for MALES which I call gtotal.   I want the subtotals to print the column header of “Total Female” Under the female header and the “Total Male” under Male header.  I can get the columns placed exactly where I want them.  But I don’t know how to place the descriptive title of Female or Male in the corresponding header. 

I was thinking to do with this with a compute statement and conditionally set the title in the Call define, but I have not been successful.  Do you have any suggestions??  Should I just contact Tech Support. I have attached the code as I cannot paste it for some reason! 

3 REPLIES 3
Cynthia_sas
SAS Super FREQ


Hi, I'm having trouble visualizing what you mean when you say, "I want the subtotals to print the column header" If you have a variable that is a computed item under an ACROSS variable, you only have 1 item, possibly repeated as many times as you have ACROSS values. For example, in the code below, I have HEIGHT, WEIGHT and TOTAL "under" the SEX variable. Just as I cannot give two different labels to HEIGHT and WEIGHT, I cannot give two different labels to TOTAL. (See screenshot.)


  So, I'm not sure what exactly you are trying to accomplish. You could apply different labels to the 'F' and 'M' values for SEX with a user-defined format for the character values, but HEIGHT, WEIGHT and TOTAL, in my example will be displayed with the SAME label under each unique value of the ACROSS variable.

 

cynthia

ods html file='c:\temp\across_header.html' style=sasweb;

title;

   proc report data=sashelp.class nowd;

     column age sex,(height weight total);

     define age / group;

     define sex / across;

     define total / computed 'Computed Total';

     define height / sum;

     define weight / sum;

     compute total;

       _c4_ = _c2_ + _c3_;

       _c7_ = _c5_ + _c6_;

     endcomp;

   run;

ods html close;


across_headers_same.png
LindaH1120
Fluorite | Level 6

Sorry for not being clear!  I want the column header to state "Total Female" under the across female columns and "Total Male" under the male across columns.  I just want the verbage in the header display either Female or Male for this calculated column.

My resolution will be to pre-total female and male and feed those results to the PROC REPORT.  Then I should be able to label the header titles whatever I wish.  However, I didn't want to have to do that, since it seemed so easy to use the calculated columns.

As always, thank you so much for your quick response

bharathtuppad
Obsidian | Level 7

proc format ;
value $gen "F" = "TOTAL FEMALE"
           "M" = "TOTAL MALE";
run;


proc report data=sashelp.class nowd;

     column age sex,(height weight total);

     define age / group;

     define sex / across;

     define total / computed 'Computed Total';

     define height / sum;

     define weight / sum;

     compute total;

       _c4_ = _c2_ + _c3_;

       _c7_ = _c5_ + _c6_;

     endcomp;
format sex $gen.;

   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
  • 3 replies
  • 940 views
  • 3 likes
  • 3 in conversation