I was trying to get decimal places for mean and median. I am only able to get decimal where there are zeros. How can I get decimals for other numbers?
Proc format;
value misszero
0 = '0.0'
other = [2.1];
run;
proc report data = fin nowindows missing headline headskip center split = "|" ps = 47 ls = 133 spanrows
style(report) = [cellwidth = 100% asis = on cellspacing = 0 cellpadding = 1.0pt borderwidth = 0.6 just = center protectspecialchars=off borderbottomcolor = black ]
style(header) = [asis = on just = center protectspecialchars=off font_weight = bold background = white fontsize=12pt ]
style(column) = [asis = on just = center protectspecialchars=off vjust = bottom fontsize=12pt ];
columns ("Assessment Time" segment_code) ("Dose Level" armcode,(N mean median));
define segment_code/"" group descending format = segmentcode.
style(column) = [just = left cellwidth = 15% font_weight = bold] style(header) = [just=left] flow id;
define armcode/"" across format = armcode.
style(column) = [just = center cellwidth = 0.12in] ;
define N/analysis sum format = 2.0
style(column) = [just = center cellwidth = 0.4in];
define mean/analysis sum format = misszero.
style(column) = [just = center cellwidth = 0.4in] ;
define median/analysis sum format = misszero.
style(column) = [just = center cellwidth = 0.4in] ;
run;
Also same output report, I want to reference the &n1, &n2 in the proc report code. I have created the macro variable but not able to use them in my proc report code. Not sure how I can use them.
Proc format;
value misszero
0 = '0.00'
other = [8.2];
run;
What would you want to do with missing values? If you've taken care of that in a previous step it's fine to ignore it though.
You need to go back to the step where you converted them to character values and do it there.
If you specify the format as 8.2 it will display with 2 decimal places. Obviously you cannot apply a numeric format to a character variable though.
mean_char = put(mean, 8.2);
@RAVI2000 wrote:
I was trying to get decimal places for mean and median. I am only able to get decimal where there are zeros. How can I get decimals for other numbers?
Proc format; value misszero 0 = '0.0' other = [2.1]; run; proc report data = fin nowindows missing headline headskip center split = "|" ps = 47 ls = 133 spanrows style(report) = [cellwidth = 100% asis = on cellspacing = 0 cellpadding = 1.0pt borderwidth = 0.6 just = center protectspecialchars=off borderbottomcolor = black ] style(header) = [asis = on just = center protectspecialchars=off font_weight = bold background = white fontsize=12pt ] style(column) = [asis = on just = center protectspecialchars=off vjust = bottom fontsize=12pt ]; columns ("Assessment Time" segment_code) ("Dose Level" armcode,(N mean median)); define segment_code/"" group descending format = segmentcode. style(column) = [just = left cellwidth = 15% font_weight = bold] style(header) = [just=left] flow id; define armcode/"" across format = armcode. style(column) = [just = center cellwidth = 0.12in] ; define N/analysis sum format = 2.0 style(column) = [just = center cellwidth = 0.4in]; define mean/analysis sum format = misszero. style(column) = [just = center cellwidth = 0.4in] ; define median/analysis sum format = misszero. style(column) = [just = center cellwidth = 0.4in] ; run;
Also same output report, I want to reference the &n1, &n2 in the proc report code. I have created the macro variable but not able to use them in my proc report code. Not sure how I can use them.
Proc format;
value misszero
0 = '0.00'
other = [8.2];
run;
What would you want to do with missing values? If you've taken care of that in a previous step it's fine to ignore it though.
As said I have created the macro variables &n1, &n2, &n3.
Can you explain how can I add them to my armcode variable?
*Counting and referencing Distinct subjects for arms;
proc sql;
select max(0, count(distinct usubjid)) into :n1 trimmed
from test
where armcode = 1;
select max(0, count(distinct usubjid)) into :n2 trimmed
from test
where armcode = 2;
select max(0, count(distinct usubjid)) into :n3 trimmed
from test
where armcode = 3;
quit;
%put &n1 &n2 &n3;
They resolve to 3, 0, 0.
Now before the proc report how do I add them to the armcode variable?
2.1 is too small. The Decimal counts as one of the 2 characters and if you have negative values that would want a character as well. It might help to show the range of values you are actually concerned with. As a minimum [3.1] will display values with 1 decimal, up to 9.9. If you have mean or median values greater than 10 you need still more width for the format such as 4.1. The number before the period is the total number of characters the format will display.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.