BookmarkSubscribeRSS Feed
SASuserlot
Barite | Level 11

I recently came across a request where I need to write a letter using the SAS. This letter involves some macro variable involved that comes through sas program. I technically don't have any data to run in ' proc report'.  I know I may have to use the 'Compute block' to write the whole letter. But I never done this before.  Image is the example how they want to see the output with random any kind of scratch notes. I also have question how to control the margins! Thank you

 

SASuserlot_0-1666044472507.png

 

6 REPLIES 6
Reeza
Super User
I think PROC ODSTEXT is a better option here than PROC REPORT?
ballardw
Super User

I strongly agree with @Reeza that Proc Odstext is likely to be much more manageable than Proc Report. For one thing Report will require a data set. If you don't provide one it will attempt to use the last created data set in some way.

 

See if this gets you started. Of course replace the filename with with what you want and appropriate to your operating system.

%let macrovar= some text placed into a macro variable;


ods rtf file="c:\folder\subfolder\example.rtf"
/*any other rtf options*/
;

proc odstext;
p "This is some boilerplate text that doesn't change";
p;
p "Here is &macrovar. as an example.";
run;

ods rtf close;

The p statements are paragraphs. I include one blank line as a separator between two lines of text. If your code for the P statement runs long enough you want to make sure there is a space either at the start of the following line or end of the previous or else you will run words together.

 

 

SASuserlot
Barite | Level 11

Thank you @ballardw @Reeza  and @Ksharp . Because of you guys I learned a  new procedure which I never used it before. I tried using the PROC ODSTEXT and I will say I achieved 80% of my requirement . There are some minor problems I am stuck at. When  you get a chance please advice on this. I am attaching two images 1.  How my results are showing up.  and 2.  How I am expecting. Thank you.

@Cynthia_sas  Can you please share your advice on this. Thank you

SASuserlot_1-1666102680146.png

 

SASuserlot_0-1666102646595.png


ods path(prepend) work.templat(update);
   proc template;
     define style styles.chk;
       parent=styles.rtf;
/*		replace fonts /*/
/*		'TitleFont' = ("Times Roman",12pt,Bold );*/
/*		'docFont' = ("Times Roman ",12pt,Bold); */
       style body from document /
             leftmargin=1in
             rightmargin=1in
             topmargin=1in
             bottommargin=1in;
       end;
   run;

%let styl= %str(/style={fontsize=12pt});
%put &styl.;

ods listing close;
title '';
options nodate nonumber;
ods rtf file="c:\folder\\example.rtf" style=styles.chk
		 ;
/*any other rtf options*/
title1 j=c  bold  "SAS Support Community";
proc odstext;

P "This community of SAS experts is here to help you succeed. Get SAS tips, share your knowledge, and find out about upcoming SAS-related events."/ style={fontsize=12pt};
P '';
p "Recent Solutions"/  style={fontsize=12pt liststyletype="none" fontweight=bold};

list / style={liststyletype="decimal" fontsize=12pt};
	item "How to show up with diff. Color in Title/SGPLOT"&styl.;
	item "ODS and Base Reporting"&styl.;
	item "Remove Duplicate Words in a String"&styl.;
	item "Watch this Ask the Expert session to learn where the SAS DATA step has a distinct advantage over SQL and where you just can’t beat SQL. "&styl.;
	
end;
P '';
p "Future Solutions"/  style={fontsize=12pt liststyletype="none" fontweight=bold};

list / style={liststyletype="decimal" fontsize=12pt};
	item "How to display by variable from proc report into ods excel file but o…"&styl.;
	item "How to left align _INFILE_ in an email";
	item "https://communities.sas.com/";

end;


run;
ods rtf close;

	

 

Ksharp
Super User

Here could give you a start.

 

data have;
infile cards truncover;
input have $200.;
cards;
This community of SAS experts is here to help you succeed. Get SAS tips, share your knowledge, and find out about upcoming SAS-related events.
.
Recent Solutions
1.How to show up with diff. Color in Title/SGPLOT
(*ESC*){unicode '25CF'x}ODS and Base Reporting
2.Remove Duplicate Words in a String
3.Watch this Ask the Expert session to learn where the SAS DATA step has a distinct advantage over SQL and where you just can’t beat SQL.
.
Future Solutions
1. How to display by variable from proc report into ods excel file but o…
2. How to left align _INFILE_ in an email
3.(*ESC*){style [color=blue url="https://communities.sas.com/"] https://communities.sas.com/}
;

ods rtf file='c:\temp\temp.rtf';
options nodate nonumber;
title1 "(*ESC*)S={fontstyle=roman}SAS Support Community";
proc report data=have nowd noheader
style={rules=none frame=void outputwidth=80% cellspacing=0 cellpadding=0} 
style(column)={fontsize=4 cellspacing=0 cellpadding=0 asis=on} ;
compute have;
n+1;
if n=2 then call define(_col_,'style','style={cellheight=60}');
if n=3 then call define(_col_,'style','style={fontweight=bold}');
if n in (4,6,7) then call define(_col_,'style','style={pretext="   "}');
if n=5 then call define(_col_,'style','style={pretext="      "}');

if n=8 then call define(_col_,'style','style={cellheight=60}');
if n=9 then call define(_col_,'style','style={fontweight=bold}');
if n in (10,11,12) then call define(_col_,'style','style={pretext="   "}');
*if n=12 then call define(_col_,'url','https://communities.sas.com/');
endcomp;
run;
ods rtf close;

Ksharp_0-1666179269135.png

 

SASuserlot
Barite | Level 11

Thank you @Ksharp  for taking your time to do this. I really appreciate. I definitely learn few newthings.😍😍

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6 replies
  • 1475 views
  • 6 likes
  • 4 in conversation