BookmarkSubscribeRSS Feed
Ksharp
Super User
>3. How does my link gets opened in a new window?


Yes. proc report can do it.Need the proper style.

[pre]



ods html file='c:\temp\testcp.html' style=sasweb;
ods escapechar='^';

proc report data=sashelp.class nowd ;
compute before _page_ ;
line '1) this is a line in purple';
line '^S={ url="http://www.sas.com" hreftarget="_blank"}' 'This is a link with an open window';

endcomp;
run;
ods html close;
[/pre]


Ksharp
Filipvdr
Pyrite | Level 9
ok thanks

next question:


/* Text before each table */
compute before _page_ / style={just=l};
text1 = "Holdcode: " || strip(Holdcode) || " Holdnote: " || strip(Holdnote) || "" ;
text2 = "Route:" || strip(route) || " ProcessEngineer: " || strip(ProcessEngineer) || " BatchEngineer: " || strip(BatchEngineer) || "" ;
text3= "Days At Operation:" || DaysOper || "" ;
line text1 $;
line text2 $;
line text3 $;
endcomp;

why is my DaysOper not coming? it is a number, the rest is character
Peter_C
Rhodochrosite | Level 12
> text3= "Days At Operation:" || DaysOper || "" ;

>
> why is my DaysOper not coming? it is a number, the rest is character

try converting that number to a string before concatenating.

text3= "Days At Operation:" || strip(put( DaysOper, 6.) ) ;
Filipvdr
Pyrite | Level 9
Days At Operation:0 i get as result for every by-variable (and this is not OK)

also:

i'm trying to do the following:

compute PreferredTool;
if upcase(ENT_STATE) not in ('UP','') then
call define (_row_,'STYLE','style={background=green}');
endcomp;

but this won't work... and the following does:

compute ENT_STATE;
if upcase(ENT_STATE) not in ('UP','') then
call define (_row_,'STYLE','style={background=green}');
endcomp;


i'm running a stored process
Filipvdr
Pyrite | Level 9
ok, number is solved...now the higlighting..
Cynthia_sas
Diamond | Level 26
Hi:
I agree with Scott. What you're doing doesn't make sense. ODS can write HTML 4.01 tags, HTML 3.2 tags, Microsoft HTML tags, WML tags, to name just a few of the HTML-related markup tags that ODS can write for you.

I notice that you are passing in a WIDTH so you can set width on your <TABLE> tag. ODS, for example, will do that for you. If you use the programs below, the OUTPUTWIDTH=80% style attribute for PROC PRINT will cause
[pre]
width: 80%;
[/pre]

to be written to the TABLE tag in the generated output. If you are trying to generate HTML without an embedded CSS section or without an HTML <HEAD> section, ODS HTML has the NO_TOP_MATTER and NO_BOTTOM_MATTER suboptions that will generate the HTML in this manner, too.

cynthia
[pre]
options center;
ods listing close;

** be sure your browser window is maximized so you can see the difference;
** look at created HTML files with NOTEPAD to see the HTML tags created;
ods html file='c:\temp\usewidth_50.html' style=sasweb;

proc print data=sashelp.prdsale(obs=10)
style(table)={outputwidth=50%};
title 'OUTPUTWIDTH=50%';
run;

ods html close;

** create microsoft-friendly HTML tags;
ods msoffice2k file='c:\temp\usewidth_80.html' style=sasweb;

proc print data=sashelp.prdsale(obs=10)
style(table)={outputwidth=80%};
title 'OUTPUTWIDTH=80%';
run;

ods msoffice2k close;

** create HTML 3.2 tags;
ods html3 file='c:\temp\usewidth_100.html' style=sasweb;

proc print data=sashelp.prdsale(obs=10)
style(table)={outputwidth=100%};
title 'OUTPUTWIDTH=100%';
run;

ods html3 close;

** use NO_TOP_MATTER and NO_BOTTOM_MATTER;
ods html file='c:\temp\use_notop.html' (NO_TOP_MATTER) style=sasweb;

proc print data=sashelp.prdsale(obs=10);;
title 'use NO_TOP_MATTER';
run;

ods html close;

ods html file='c:\temp\use_nobot.html' (NO_BOTTOM_MATTER) style=sasweb;

proc print data=sashelp.prdsale(obs=10);;
title 'use NO_BOTTOM_MATTER';
run;

ods html close;
[/pre]
chang_y_chung_hotmail_com
Obsidian | Level 7
I don't think any pre-existing ODS destination would give a clean HTML snippet that OP wants to generate and to flush out into _webout.

But you can do this with a very simple (in fact, some would say, elementary) custom tagset that listens to only a few events.



As it is, a variable can take a maximum of one row and one column (equality) filters. Thus, there can be as many row/column filters as the number of variables. (Can you see why?)

It is really easy to modify this tagset so that it can take multiple row/column filters for each var. This is left as an exercise for those who are interested. 🙂


It may be a bit more involved to generalize this so that the "filter" accommodates non-equality as well.

For those who are trying, here is a hint:

It would involve users writing the filters using a marker (or a place holder) for the variable in the expression,

so that the tagset can replace the marker with actual value of the cell and evaluate the expression.

A natural marker may be the variable name itself.
This is not really that involved at all.



P.S. Please don't be alarmed by the red-colored keywords that look like errors ("undefined keywords") -- they are not.

Come on, the editor dev team!
This has been available all along ...



   /* prepend a template store, work.myTmp to ods path */


   ods path (prepend) work.myTmp(update);


 


   /* create a tagset, hfTab - html table with "filtering" */


   proc template;


      define tagset tagsets.hfTab;


 


         /* ods events */


         define event option;


            set $name upcase(name);


            set $options[$name] value; /* collect options specified */


         end;


 


         define event table_body;  


            start: 


               trigger openTable;


               trigger doHeaders;


            finish: 


               trigger closeTable;


         end;


 


         define event colspec_entry;


            break /if cmp(name, 'obs'); /* ignore the obs column */


            set $names[] name;          /* collect column names */


         end;


 


         define event row;       


            start:                      /* some init for each row */


               break /if ^$inTable;


               unset $trClasses;


               unset $tds;


 


            finish:                       


               break /if ^$inTable;


 


               unset $class;            /* open tr with classes, if any */


               iterate $trClasses;


               do /while _value_;


                 set $class catx(' ', $class, _value_);


                 next $trClasses;


               done;


               put "<tr";


               put " class='" $class "'" /if ^missing($class);


               put ">";


 


               iterate $tds;            /* output cells in the row */


               do /while _value_;


                 put _value_;


                 next $tds;


               done;


 


               putl "</tr>";            /* close tr tag */


         end;


 


         define event data;


            set $name upcase(name);


 


            /* if column name matches a column filter then add a class attribute */


            do /if $cfClasses[$name];


               set $tds[] "<td class='" $cfClasses[$name] "'>" value "</td>";


            else;


               set $tds[] "<td>" value "</td>";


            done;


 


            /* if the cell matches a row filter then collect the class name */


            set $trClasses[] $rfClasses[$name] /if cmp($rfValues[$name], value);


         end;


      


         /* user events */


         define event openTable;


            put "<table";


            put " width=" quote($options["WIDTH"]) /if $options["WIDTH"];


            putl ">";


            trigger parseRowFilters /if $options["ROWFILTERS"];


            trigger parseColFilters /if $options["COLFILTERS"];


 


            set $inTable "True";


         end;


         define event doHeaders;


            put "<tr>";


            iterate $names;


            do /while _value_;


               set $name upcase(_value_);


               do /if $cfClasses[$name];


                  put "<th class='" $cfClasses[$name] "'>" _value_ "</th>";


               else;


                  put "<th>" _value_ "</th>";


               done;


               next $names;


            done;


            putl "</tr>";


         end;


         define event closeTable;


            putl "</table>";


            


            unset $options;


            unset $inTable;


            unset $names;


         end;


 


         /* for parsing filter options */


         define event parseRowFilters;


            set $str $options["ROWFILTERS"];


            trigger getList;


            iterate $list;


            do /while _value_;


               set $var scan(_value_, 1);


               set $var upcase($var);


               set $rfValues[$var] scan(_value_, 2);


               set $rfClasses[$var] scan(_value_, 3);


               next $list;


            done;


            unset $list;


         end;


         define event parseColFilters;


            set $str $options["COLFILTERS"];


            trigger getList;


            iterate $list;


            do /while _value_;


               set $var scan(_value_, 1);


               set $var upcase($var);


               set $cfClasses[$var] scan(_value_, 2);


               next $list;


            done;


            unset $list;


         end;


 


         /* utility */


         define event getList;


            /* given $str of a delimited list, returns a list, $list[] */


            break /if missing($str);


            set $dlm ",";


            eval $i 1;


            set $item scan($str, $i, $dlm);


            do /while ^missing($item);


               set $list[] strip($item);


               eval $i $i + 1;


               set $item scan($str, $i, $dlm);


            done;


         end;


 


         /* quote those (in)famous five */


         map = %nrstr("<>&'""");  


         mapsub = %nrstr("/&lt;/&gt;/&amp;/&#39;/&quot;/");


      end;


   run;


 


   /* usage */


   ods tagsets.hfTab file=_webout 


      options(width='100%' colfilters='weight weight'


      rowfilters='sex F girl, name Thomas thomas, age 12 twelve');


      proc print data=sashelp.class;


        where age <= 12;


      run;


   ods tagsets.hfTab close;


   /* _webout


   <table width="100%">


   <tr><th>Name</th><th>Sex</th><th>Age</th><th>Height</th><th class='weight'>Weight</th></tr>


   <tr class='twelve'><td>James</td><td>M</td><td>12</td><td>57.3</td><td class='weight'> 83.0</td></tr>


   <tr class='girl twelve'><td>Jane</td><td>F</td><td>12</td><td>59.8</td><td class='weight'> 84.5</td></tr>


   <tr class='twelve'><td>John</td><td>M</td><td>12</td><td>59.0</td><td class='weight'> 99.5</td></tr>


   <tr class='girl'><td>Joyce</td><td>F</td><td>11</td><td>51.3</td><td class='weight'> 50.5</td></tr>


   <tr class='girl twelve'><td>Louise</td><td>F</td><td>12</td><td>56.3</td><td class='weight'> 77.0</td></tr>


   <tr class='twelve'><td>Robert</td><td>M</td><td>12</td><td>64.8</td><td class='weight'>128.0</td></tr>


   <tr class='thomas'><td>Thomas</td><td>M</td><td>11</td><td>57.5</td><td class='weight'> 85.0</td></tr>


   </table>


   */


 


   /* clean up */


   ods path reset;





Message edited: "Filtering" implemented. by [email protected] on 2011-01-12
Cynthia_sas
Diamond | Level 26
Hi:
Well, CHTML and PHTML destinations come really close to very sparse HTML -- especially the CHTML destination.

cynthia
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
In my experience with ODS-generated output, it's much easier to parse SAS-generated HTML for any required manipulation than having to maintain a SAS program to generate the HTML tag statements for whatever is being created. I can't imagine having to turn this type of code-piece over to someone else, expecting that individual to embrace the same technical approach, frankly.

Scott Barry
SBBWorks, Inc.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 23 replies
  • 8518 views
  • 0 likes
  • 7 in conversation