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

I'm trying to add total row header and received an error messages because the Group variable is numeric.   Can anyone recommend a solution?

 

26 data tab1;
27 input c $ year benes death;
28 list;
29 datalines;

RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
30 a 2009 1 1
31 a 2010 1 0
32 a 2009 1 0
33 a 2010 1 1
34 a 2010 1 0
35 a 2010 1 0
36 b 2009 1 1
37 b 2010 1 0
38 b 2009 1 0
39 b 2010 1 0
NOTE: The data set WORK.TAB1 has 10 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds

40 ;

41 run;
42
43 proc format;
44 value dec
45 0='No'
46 1='Yes'
47 ;
NOTE: Format DEC is already on the library WORK.FORMATS.
NOTE: Format DEC has been output.
2 The SAS System 11:28 Thursday, March 18, 2021

48 value missnum
49 . = '0'
50 other=[comma8.]
51 ;
NOTE: Format MISSNUM is already on the library WORK.FORMATS.
NOTE: Format MISSNUM has been output.
52 value missdec
53 . = '0'
54 other=[8.2]
55 ;
NOTE: Format MISSDEC is already on the library WORK.FORMATS.
NOTE: Format MISSDEC has been output.
56 value misspct
57 . = '0.0%'
58 other=[percent7.1]
59 ;
NOTE: Format MISSPCT is already on the library WORK.FORMATS.
NOTE: Format MISSPCT has been output.
60 run;

NOTE: PROCEDURE FORMAT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

61
62 proc report data=tab1 split='~';
63 columns c year benes=benessum ('deceased' death, benes) death=decpct
64 ('rate' death, benes=rate1) benes=rate2 ('increase likelihood~of disenrollment' likelihood);
65 define c /group ;
66 define year / group;
67 define benessum / sum 'Benes' format=missnum.;
68 define death / across '' format=dec. missing;
69 define benes / analysis '' sum format=missnum.;
70 define decpct / analysis 'pct deceased' mean format=misspct.;
71 define rate1 / analysis '' pctsum format=misspct.;
72 define rate2 / analysis 'pct of cohort' pctsum format=misspct.;
73 define likelihood / computed ''
74 format=missdec.;
75 break after c / summarize;
76 rbreak after / summarize;
77 compute after c;
78 year = 'Total';
79 endcomp;
80 compute after;
81 c='Total';
82 endcomp;
83 compute likelihood;
84 likelihood=_c8_/_c7_;
85 endcomp;
86
87 run;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
1:9
NOTE: Invalid numeric data, 'Total' , at line 1 column 9.
NOTE: Invalid numeric data, 'Total' , at line 1 column 9.
NOTE: Missing values were generated as a result of performing an operation on missing values.
3 The SAS System 11:28 Thursday, March 18, 2021

Each place is given by: (Number of times) at (Line):(Column).
1 at 1:17
NOTE: There were 10 observations read from the data set WORK.TAB1.
NOTE: At least one W.D format was too small for the number to be printed. The decimal may be shifted by the "BEST" format.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.32 seconds
cpu time 0.03 seconds

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  For using a numeric variable as the column where you want to display something on the break (typically, the numeric variable is either GROUP or ORDER). I used this example, because I already had it and I didn't want to edit the code out of your posted LOG.

Cynthia_sas_0-1616099115307.png

  Using NOPRINT for the numeric column and then computing a character column of the right length just for display purposes is the technique I use (here I have a very long string, just to illustrate the point).

 

Cynthia

View solution in original post

1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:

  For using a numeric variable as the column where you want to display something on the break (typically, the numeric variable is either GROUP or ORDER). I used this example, because I already had it and I didn't want to edit the code out of your posted LOG.

Cynthia_sas_0-1616099115307.png

  Using NOPRINT for the numeric column and then computing a character column of the right length just for display purposes is the technique I use (here I have a very long string, just to illustrate the point).

 

Cynthia

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 1 reply
  • 830 views
  • 1 like
  • 2 in conversation