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

Hi,

 

i'm trying to set colomns width for each column of an across variable in a proc report.

 

This is my dataset structure:

STRATA1STRATA2_NAME_COL1
CAT1CAT2NObs1xx
CAT1CAT2meanxxx
CAT1CAT2stdxxx
CAT1CAT2medianxxx
CAT1CAT2Q13xxx; xxx
CAT1CAT2Minmaxxxx; xxx

 

 

This is the format code:

proc format ;
value $label 
	  "N" =  "N"
	  "NObs1" = "n"
	  "mean" = "Mean"
      "median" = "Median"
	  "std" = "Std Dev"
	  "Q13" = "Q1; Q3"
	  "Minmax" = "Min; Max"

;
run;

 

This is the proc report code:

 

goptions device=png;
ods listing close;
options nodate nonumber orientation = landscape nobyline;
ods rtf file= "file.rtf"  style = customtemp;
title1 j=l "title";
proc report data=report missing nowd split="|" style(header)={just = center} ;
columns ("" STRATA1 STRATA2)  ( _NAME_,(COL1)) dummy ;

define STRATA2  /' ' group style(column)={cellwidth=0.08in just = left};
define STRATA1  /' ' group style(column)={cellwidth=0.08in just = left};
define _NAME_ /' ' nozero across order = data style(column)={just = center} format = $label.;
define COL1   /' ' style(column)={cellwidth=0.10in just = center};
define dummy  /computed noprint;

compute _NAME_;

	if compress(_NAME_) = 'NObs1' then call define(_col_, "style/merge", "style=[cellwidth=0.03in]");  
	else if compress(_NAME_) = 'mean' then call define(_col_, "style/merge", "style=[cellwidth=0.04in]"); 
	else if compress(_NAME_) = 'median' then call define(_col_, "style/merge", "style=[cellwidth=0.04in]"); 
	else if compress(_NAME_) = 'std' then call define(_col_, "style/merge", "style=[cellwidth=0.04in]"); 
	else if compress(_NAME_) = 'Q13' then call define(_col_, "style/merge", "style=[cellwidth=0.05in]"); 
	else if compress(_NAME_) = 'Minmax' then call define(_col_, "style/merge", "style=[cellwidth=0.05in]");  

endcomp;

run;
ods rtf close;

 

It does not change the columns width.

I also tryed with the following code with the same result.

 

compute _NAME_;

	if compress(_NAME_) = 'NObs1' then call define('NObs1', "style/merge", "style=[cellwidth=0.03in]");  
	else if compress(_NAME_) = 'mean' then call define('mean', "style/merge", "style=[cellwidth=0.04in]"); 
	else if compress(_NAME_) = 'median' then call define('median', "style/merge", "style=[cellwidth=0.04in]"); 
	else if compress(_NAME_) = 'std' then call define('std', "style/merge", "style=[cellwidth=0.04in]"); 
	else if compress(_NAME_) = 'Q13' then call define('Q13', "style/merge", "style=[cellwidth=0.05in]"); 
	else if compress(_NAME_) = 'Minmax' then call define('Minmax', "style/merge", "style=[cellwidth=0.05in]");  

endcomp;

could you help me?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

0.04in and similar  is likely the culprit. A cell that small very likely does not have room for more than one character.

Are you getting any messages in the log?

 

Here is an example of using a format to set the width of the column based on the value of the Name.

proc format;
value $cw
"N" =  ".5in"
"NObs1" = "1in"
"median" = "1.5in"
;
run;

data junk;
  input row name $ value;
datalines;
1 N  2300
2 Nobs1 110
3 median 17.4
;

proc report data=junk;
   columns row name, value;
   define row /group;
   define name /across style=[cellwidth=$cw.];
run;

You can use the same approach to change font, text color, background color and most items that appear in a style block for a cell.

View solution in original post

2 REPLIES 2
ballardw
Super User

0.04in and similar  is likely the culprit. A cell that small very likely does not have room for more than one character.

Are you getting any messages in the log?

 

Here is an example of using a format to set the width of the column based on the value of the Name.

proc format;
value $cw
"N" =  ".5in"
"NObs1" = "1in"
"median" = "1.5in"
;
run;

data junk;
  input row name $ value;
datalines;
1 N  2300
2 Nobs1 110
3 median 17.4
;

proc report data=junk;
   columns row name, value;
   define row /group;
   define name /across style=[cellwidth=$cw.];
run;

You can use the same approach to change font, text color, background color and most items that appear in a style block for a cell.

g_lanzi
Calcite | Level 5

Thank you very much!! I had not considered the possibility of providing the information as a format, real interesting solution. ps. there was no erorr in the log

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
  • 3554 views
  • 2 likes
  • 2 in conversation