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

Hi all, 

 

I am trying to output a docx file using SAS. I was having some issues with formatting using RTF so I wanted to give docx a try. I am using SAS 9.4 TS1M6 in which ODS word is in preproduction. When I try to open the outputted docx, I am getting the error you see below. I have attached some sample code to mimic what I am doing, but it is really not all too complicated. I also provided the link to a paper I was using on the subject. Anyone have an idea how to prevent this error? For what it is worth, when I output this using ODS RTF and .RTF (instead of .docx) it works just fine.

 

data mydata;
   input var1 $ var2 $ var3 $ var4 $;
   datalines;
18-24 10.00% .5 1
25-34 10.00% .5 1
35-44 10.00% .5 1
45-54 10.00% .5 1
55-64 10.00% .5 1
;

ods escapechar="^"; 
%Let year_range=Jan 2018 – Dec 2018; proc format; value $ sym '1' = '^{unicode 2713}'; run; %macro hex2(n); %local digits n1 n2; %let digits = 0123456789ABCDEF; %let n1 = %substr(&digits, &n / 16 + 1, 1); %let n2 = %substr(&digits, &n - &n / 16 * 16 + 1, 1); &n1&n2 %mend hex2; /* convert RGB triplet (r,g,b) to SAS color in hexadecimal. The r, g, and b parameters are integers in the range 0--255 */ %macro RGB(r,g,b); %cmpres(CX%hex2(&r)%hex2(&g)%hex2(&b)) %mend RGB; ODS word file="locationhere\name.docx"; proc report data=mydata split='*' style(hdr)=[foreground = Black background=%RGB(126,172,147) font_size=2.5 font_face=Arial verticalalign=m height=.52in just=c] spanrows style(column)=[font_size=1.8 font_face=Arial height=.35in verticalalign=m background=%RGB(255,255,255)]; define var1 / display 'Var1' style=[cellwidth=2.1in]; define var2 / display "Var2* &year_range" style=[cellwidth=1.5in just=c]; define var3 / display 'Var3' style=[cellwidth=1.5in just=c]; define var4 / display 'Var4' style(column)=[just=c font_size=4 cellwidth=1.4in verticalalign=m font_face=Arial]; format var4 $sym.; run; ODS word CLOSE;

 

https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3235-2019.pdf

 

image.png

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

My typical approach to sleuthing out ODS odd behaviors is to comment out ALL style overrides and see what the result is. If no problem, then to add things in back one at a time until you get the misbehavior. At which point you have someplace to look at what may be causing and issue.

 

I suggest when providing sizes, such as FONT_SIZE to use a measurement but Font_size AND Height in the same style override look like a potential for conflict. I would suggest pick just one, likely Font_size, and see if that helps.

View solution in original post

4 REPLIES 4
mitchell_keener
Obsidian | Level 7

Hi Kurt, 

 

My apologies. I updated the sample code and it should now allow you to recreate the issue I am experiencing. Thank you. 

 

 

ballardw
Super User

My typical approach to sleuthing out ODS odd behaviors is to comment out ALL style overrides and see what the result is. If no problem, then to add things in back one at a time until you get the misbehavior. At which point you have someplace to look at what may be causing and issue.

 

I suggest when providing sizes, such as FONT_SIZE to use a measurement but Font_size AND Height in the same style override look like a potential for conflict. I would suggest pick just one, likely Font_size, and see if that helps.

mitchell_keener
Obsidian | Level 7

Thanks so much for the response. For what it is worth, I just removed all of the style overrides and I was able to output the document. I will need to explore further to see which specifically was causing the issue but this at least will get me on the right track! 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1264 views
  • 0 likes
  • 3 in conversation