BookmarkSubscribeRSS Feed
dstephenson
Calcite | Level 5

In the proc report I'm creating, I'm needing the left margin or indent to dynamically change with the value of a variable (which I have named "indent"). 

I have had this work before, with the exact same code, so I'm at a loss as to why it is suddenly not working correctly now. 

Now, it is working for only some of my lines and just.... not working on the rest. 

 

Code: 

	compute textcol;
		if indent = 1 then do;
			call define(_col_, 'style', 'style={leftmargin=.22in}');
		end;
		if indent = 2 then do;
			call define(_col_, 'style', 'style={leftmargin=.38in}');
		end;
	endcomp;

Data: 

dstephenson_0-1644605371802.png

 

Current Output: 

dstephenson_1-1644605409813.png

 

Any ideas what could be causing this? A setting in the rtf template maybe?? 

2 REPLIES 2
ballardw
Super User

Really need to show the entire procedure code and possibly even the ODS destination and style options in effect.

 

And probably should include some example data. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

Cynthia_sas
SAS Super FREQ

Hi:
I agree with @ballardw -- the order of the variables in the column statement can impact what you're doing. Also the usage type of the INDENT variable can have an impact. Showing your data is useful, but showing the code is better. I don't quite understand how you're getting Courier New looking fonts out of PROC REPORT since the default font for most destinations is a fixed pitch font. So that's another question about what might be in your code.

 

  In doing a quick test with some fake data, I see that LEFTMARGIN works for me in RTF and PDF output reports. I would not expect this to work in HTML or LISTING destinations. Here's an example in the PDF output file:

Cynthia_sas_0-1644616647432.png

The RTF file looks the same. I made helper variables called row_ord and linenum in addition to indent and text variables. The code I used is shown below:

Cynthia_sas_1-1644616717627.png

Note that in my code the INDENT variable is given a DISPLAY usage. If it was a numeric variable with the default analysis usage I would have needed to change the code in the COMPUTE block.

 

Cynthia


Cynthia

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