BookmarkSubscribeRSS Feed
CP20
Fluorite | Level 6

Hi All,

Thanks for the help in Advance!

So here's what I am trying to do - 

I have a macro variable which holds values like "OutText.. (InText..)" [with brackets]. This macro variable will act as a label for a column statement in PROC REPORT. - which will be coded as - 

column ("&macro_var &space &OtherText" var1 var2 var3...varn))

 

Macro variable &space will be "Total" number of spaces between &macro_var and &OtherText. &OtherText is just another macro variable. Values of &space changes on different iterations.

 

Now I am using pdf anchor, ods proclabel and proc document to replay my output in PDF.  The problem is that the column label will be printed as - 1) 1st line - it will show from 1st character to the start of brackets. 2) 2nd line - From start of brackets till end of column label.

I am not sure why SAS auto breaks the line at the start of the brackets. Am I missing something here? If I give a constant text to &macro_Var, it is working but not with the values in the macro variables

 

Any help is appreciated!

 

Thanks!

 

4 REPLIES 4
ballardw
Super User

Did you have a version of this that worked as intended before adding all the macro elements?

 

There are likely a number of elements that could affect this, the cell width of where you are placing the text (too narrow and text wraps), width of table (too wide and the columns might get adjusted), font face and size (larger takes up more width and again the cell width comes into effect).

 

If you are not setting a cellwidth that might help though calculating an exact variable width is "entertaining" in general.

 

One approach if by "space" you actual have a variable that contains multiple space characters, not exactly clear in the definition, is to use a different character such as a NULL, ASCII 255, instead of a space. Many of the heuristics involved in adjusting text do not treat null the same as a space.

 

Another approach might be to use a single macro variable created from the ones you have though I don't really expect that to work.

CP20
Fluorite | Level 6

Thanks ballardw!

 

-This is my first attempt only. There is no previous version. 

- Question of width/cell wrap won't be there cause the label applies to full table (atop of 6 variables) i.e. width of the page.

 

Here is the test program which also results into same issue - 

 

NOTE that if we remove &space variable, it works fine.

 

ods pdf file = ".\test.pdf";
data a1;
set sashelp.cars;
run;

%let mc1 = %nrstr(Check brackets (BR));
%global space;

data _null_;
space = repeat(' ', 70);
call symput ('space',space);
run;

proc report data = a1;
column ("&mc1 &space xyz" make model) ;
run;

ods pdf close;

 

Thanks!

ballardw
Super User

@CP20 wrote:

Thanks ballardw!

 

-This is my first attempt only. There is no previous version. 

- Question of width/cell wrap won't be there cause the label applies to full table (atop of 6 variables) i.e. width of the page.

 

Here is the test program which also results into same issue - 

 

NOTE that if we remove &space variable, it works fine.

 

ods pdf file = ".\test.pdf";
data a1;
set sashelp.cars;
run;

%let mc1 = %nrstr(Check brackets (BR));
%global space;

data _null_;
space = repeat(' ', 70);
call symput ('space',space);
run;

proc report data = a1;
column ("&mc1 &space xyz" make model) ;
run;

ods pdf close;

 

Thanks!


So what is the insertion of 70 spaces supposed to accomplish? As a minimum that makes the column label about 88 characters long which is way wider than the example table wants to use to align with the data columns.

 

In the example the inserted spaces tell SAS that you want a long label but the rules for inserting text in general say strip leading and/or trailing spaces when wrapping text

 

CP20
Fluorite | Level 6

Thanks again for checking out the code!

 

And extremely sorry, I wasn't bit clear before.  All I want is that the 1st macro variable (mc1) to be on the far left and the second text xyz to be on the far right side of the column label. Now, during execution, length of both variables will change and hence the value of &space will too. So with &space I was planning to accomplish far left and far right texts. 

 

For now, I set it to 70 for testing purpose. Also even if we increase the width (in proc report) and length of those column variables (say to $200) to accommodate all 70 spaces and all the text, it is still not working.

 

I am bit confused here as what is happening. 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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