BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ScottBass
Rhodochrosite | Level 12
* option 1 ;
data _null_;
   file print;
   msg="Testing 1,2,3";
   put msg;
run;

* option 2 ;
data _null_;
   file print ods;
   msg="Testing 1,2,3";
   put msg _ods_;
run;

 

SAS 9.3

 

I've skimmed http://www2.sas.com/proceedings/sugi30/088-30.pdf.

 

All I want to do is print the text red bold so it stands out, and also suppress the variable name.  It's an error message in a stored process called from EG.

 

I suppose I could use proc template; I was hoping I didn't have to for such a simple task.

 

I just want option 2 to mimic option 1, but in red bold.  I suppose centered within the current linesize would be cool too.

 

 

 

 

 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  And to modify RW9's suggestion, you can add a blank label statement to get rid of the header, but not of the area reserved for the header.

 

  But PROC REPORT could do it for you without a header and without a template.

 

cynthia

 


ods html(id=msg1) file='c:\temp\message1.html';
ods escapechar='^';
data _null_;
   file print ods;
   msg="^{style[color=red font_weight=bold font_size=20pt]Testing 1,2,3}";
   put @1 msg ;
   label msg = ' ';
run;
ods html(id=msg1) close;
    
ods html(id=msg2) file='c:\temp\message2.html';
ods escapechar='^';
data msg;
   msg="Testing 1,2,3";
run;
  
proc report data=msg noheader;
  column msg;
  define msg / display style(column)={color=red font_weight=bold font_size=20pt};
run;
ods html(id=msg2) close;

View solution in original post

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Have you tried inline formatting:

ods escapechar='^';

data _null_;
   file print;
   put '^S={foreground=red}Testing 1,2,3';
run;
Cynthia_sas
SAS Super FREQ

Hi:

  And to modify RW9's suggestion, you can add a blank label statement to get rid of the header, but not of the area reserved for the header.

 

  But PROC REPORT could do it for you without a header and without a template.

 

cynthia

 


ods html(id=msg1) file='c:\temp\message1.html';
ods escapechar='^';
data _null_;
   file print ods;
   msg="^{style[color=red font_weight=bold font_size=20pt]Testing 1,2,3}";
   put @1 msg ;
   label msg = ' ';
run;
ods html(id=msg1) close;
    
ods html(id=msg2) file='c:\temp\message2.html';
ods escapechar='^';
data msg;
   msg="Testing 1,2,3";
run;
  
proc report data=msg noheader;
  column msg;
  define msg / display style(column)={color=red font_weight=bold font_size=20pt};
run;
ods html(id=msg2) close;
ScottBass
Rhodochrosite | Level 12

There's a bug in the forum software when you click on Preview and have embedded SAS code, then edit that post. 

 

The gist is I lost the surrounding commentary of this post, and it's not worth recreating in lieu of my follow on post.

 

Since I can't delete this post, here is the remnants of that post, superceded by the below post:

 

ods escapechar='^';

data _null_;
   file print ods;
   msg="^{style[color=red font_weight=bold font_size=12pt]Testing 1,2,3}";
   put @1 msg ;
   label msg = ' ';
run;
 
data msg;
   msg1="Testing 1,2,3";
   msg2="^{style[color=red font_weight=bold font_size=12pt]Testing 1,2,3}";
run;

proc print data=msg noobs label;
   var msg2;
   label msg2='00'x; * a simple space does not work ;
run;
 
proc report data=msg noheader;
   column msg1;
   define msg1 / display style(column)={color=red font_weight=bold font_size=12pt};
run;

proc report data=msg noheader;
   column msg2;
   define msg2 / display;
run;

proc delete data=msg;
run;

 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
ScottBass
Rhodochrosite | Level 12

Further Googling led me to this usage note:  http://support.sas.com/kb/23/353.html

 

I assume there is no way to create "enhanced output" via data _null_ / file print ods without using proc template.  For my purposes, that's more effort than I want to expend to just color code an error message.

 

Embedding style data within the data itself does not seem to work.

 

Here is some additional code, with both proc print and proc report creating enhanced output:

 

ods escapechar='^';

data _null_;
   file print;
   msg="Testing 1,2,3";
   put msg;
run;

data _null_;
   file print ods;
   msg="^{style[color=red font_weight=bold font_size=12pt]Testing 1,2,3}";
   put @1 msg;
   label msg = '00'x;
run;
     
data msg;
   msg1="Testing 1,2,3";
   msg2="^{style[color=red font_weight=bold font_size=12pt]Testing 1,2,3}";
run;

proc print data=msg noobs label;
   var msg1 / style={color=red font_weight=bold font_size=12pt};
   label msg1='00'x; * a simple space does not work ;
run;
 
proc print data=msg noobs label;
   var msg2;
   label msg2='00'x; * a simple space does not work ;
run;
 
proc print data=msg noobs label;
   var msg2 / style={color=red font_weight=bold font_size=12pt};
   label msg2='00'x; * a simple space does not work ;
run;
 
proc report data=msg noheader;
  column msg1;
  define msg1 / display style(column)={color=red font_weight=bold font_size=12pt};
run;

proc report data=msg noheader;
  column msg2;
  define msg2 / display;
run;

proc delete data=msg;
run;

2016-11-29_8-49-22.png

Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

 

Sorry, it wasn't clear to me what "wasn't working", the color seems to work on all those statements for me other than the first.  

 

Also, I think you may have a misonception here.  The log file is the place for errors/warnings and such like, color coding is defined there by the use of those keywords.  Output window is for output, i.e. report/print and procedure output.  Normally this is plain text, however you can set it to HTMLwhich then has the formatting.  However that being said, if your producing output then you would find it far simpler and more robust to produce a report, than putting out bits of text there.  Its not difficult to have an errors dataset, which you insert each problem you come across into, and then at the end proc report this to a file.

 

ScottBass
Rhodochrosite | Level 12

I've edited my previous post, attaching a screenshot of the results in my EG6.1M1 / SAS 9.3 environment.

 

Thanks for the advice regarding coding approaches.  For my particular application I am happy with my current approach - using the output window to give feedback to the end user, including error messages.

 

If we had SAS/AF licensed (and I had a mandate to use it), I would use it rather than EG for this particular programming task.  I could use a custom task for this but that too is not mandated by my mangement or end users.

 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Must be your setup/process then.  In 9.4 normal SAS it works fine.  Am afraid I don't have EG to check that.  I would really not recommend using AF, I can't think of anything more clunky/outdated than that.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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