Experiment Displaying SAS Code in Wiki

From sasCommunity

Jump to: navigation, search

Contents

[edit] Learning to use the wiki editor

This is my first section. After reading the Help: Syntax Summary I will try different ways of formatting SAS code to make it display properly in this wiki page.

[edit] Getting used with wiki syntax

[edit] Formatting SAS code

Tip: To view the code both as it is typed and as it is displayed, use the "edit" tab (top of the page) then select the "show preview" button at the bottom of that page.

[edit] Default formatting

  • =============================*;
  • Comments box *;
  • =============================*;
  • - Printing sample data -*;

%let sect = where sex in ('M'); proc print data=sahelp.class; § run;

Notice, the macro-variable &sect followed by a semi-colon is interpreted as a character entity reference for the special character ยง (paragraph or section). To avoid this, you can:

  • add a space before the semicolon:

&sect ;

  • add a period after the macro-variable name:

&sect.;

  • replace the ampersand character by its character entity reference (&):

§

[edit] Using tag: <nowiki>

*=============================*; * Comments box *; *=============================*; *- Printing sample data -*; %let sect = where sex in ('M'); proc print data=sahelp.class; § run;

[edit] Using tag: <pre>

*=============================*;
* Comments box                *;
*=============================*;
*- Printing sample data -*;
%let sect = where sex in ('M');
proc print data=sahelp.class;
§
run;

[edit] Using leading spaces (indentation)

  *=============================*;
  * Comments box                *;
  *=============================*;
  *- Printing sample data -*;
  %let sect = where sex in ('M');
  proc print data=sahelp.class;
     §
  run;

[edit] Using tag <tt> (teletype)

  • =============================*;
  • Comments box *;
  • =============================*;
  • - Printing sample data -*;

%let sect = where sex in ('M'); proc print data=sahelp.class; § run;

[edit] Using tag <code>

  • =============================*;
  • Comments box *;
  • =============================*;
  • - Printing sample data -*;

%let sect = where sex in ('M'); proc print data=sahelp.class; § run;


[edit] Using tag <source> with parameter lang=sas (not supported) :-(

<source lang="sas">

  • =============================*;
  • Comments box *;
  • =============================*;
  • - Printing sample data -*;

%let sect = where sex in ('M'); proc print data=sahelp.class; § run; </source>

[edit] Using combined tags <tt> (teletype) and <pre>

*=============================*;
* Comments box                *;
*=============================*;
*- Printing sample data -*;
%let sect = where sex in ('M');
proc print data=sahelp.class;
§
run;
<tt>
*=============================*;
* Comments box                *;
*=============================*;
*- Printing sample data -*;
%let sect = where sex in ('M');
proc print data=sahelp.class;
§
run;
</tt>

[edit] Using combined tags <tt> (teletype) and <nowiki>

*=============================*; * Comments box *; *=============================*; *- Printing sample data -*; %let sect = where sex in ('M'); proc print data=sahelp.class; § run;

<tt> *=============================*; * Comments box *; *=============================*; *- Printing sample data -*; %let sect = where sex in ('M'); proc print data=sahelp.class; § run; </tt>


[edit] Masking character entity references

In HTML syntax, specific names (characters) preceded by the ampersand character (&) and followed by the semicolon character (;) are recognized as character entity reference and displayed as special characters. An effective way to prevent this is to always replace the & character in SAS code by its own character entity reference (&amp;).

[edit] Using tag: <nowiki> and masking character references

*=============================*; * Comments box *; *=============================*; *- Printing sample data -*; %let sect = where sex in ('M'); proc print data=sahelp.class; &sect; run;

[edit] Using tag: <pre> and masking character references (preferred) ;-)

*=============================*;
* Comments box                *;
*=============================*;
*- Printing sample data -*;
%let sect = where sex in ('M');
proc print data=sahelp.class;
&sect;
run;

[edit] Using leading spaces (indentation) and masking character references (preferred) ;-)

  *=============================*;
  * Comments box                *;
  *=============================*;
  *- Printing sample data -*;
  %let sect = where sex in ('M');
  proc print data=sahelp.class;
     &sect;
  run;



--Jmbodart 10:03, 8 September 2008 (EDT)

Personal tools