<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>tous-les-niveaux &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/tous-les-niveaux/</link>
	<description>Feed of posts on WordPress.com tagged "tous-les-niveaux"</description>
	<pubDate>Fri, 01 Jan 2010 01:10:44 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Ces caractères hexadécimaux non visibles au 1er coup d'oeil]]></title>
<link>http://thesasreference.wordpress.com/2009/11/23/format_hex/</link>
<pubDate>Mon, 23 Nov 2009 18:05:38 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/11/23/format_hex/</guid>
<description><![CDATA[Lors de l&#8217;importation de données d&#8217;un fichier Excel, il est fréquent d&#8217;importer au]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Lors de l&#8217;importation de données d&#8217;un fichier Excel, il est fréquent d&#8217;importer au passage des caractères spéciaux non visible au premier coup d&#8217;œil. Par exemple, on peut trouver des blancs représentés en valeur hexadécimale par le code 20. Certains de ses caractères ressemblent à des blancs mais n&#8217;en sont pas. Ils ne disparaîtront donc pas avec une fonction COMPRESS sans troisième paramètre. La valeur hexadécimale de ces caractères est par contre une valeur lisible.</p>
<p>Voici comment afficher votre texte en valeur hexadécimale et ce dans la log ?</p>
<p><strong><span style="color:#ff6600;">1. Illustration du problème</span></strong></p>
<p>Dans cet exemple, une variable WEBISTE de longueur 25 est présente dans la table HEXFMT. Cette variable contient une observation www.sasreference.fr entourée d&#8217;un blanc avant et d&#8217;un blanc après. Cette valeur est créée ici au moyen de la fonction CAT.</p>
<p>Pour voir la différence entre la valeur de WEBSITE avec et sans un simple COMPRESS, une seconde variable EQUAL indique la valeur YES si les deux résultats sont identiques, NO sinon.</p>
<p><span style="font-family:courier;"><strong><span style="color:#000080;">data</span></strong> hexfmt;<br />
<span style="color:#0000ff;">length</span> website $<span style="color:#008080;"><strong>25</strong></span> equal $<span style="color:#008080;"><strong>3</strong></span>;<br />
website=cat(<span style="color:#800080;">&#8216;20&#8242;</span>x,<span style="color:#800080;">&#8216;www.sasreference.fr&#8217;</span>,<span style="color:#800080;">&#8216;20&#8242;</span>x);<br />
<span style="color:#0000ff;">if</span> website=compress(website) <span style="color:#0000ff;">then</span> equal=<span style="color:#800080;">&#8216;Yes&#8217;</span>;<br />
<span style="color:#0000ff;">else</span> equal=<span style="color:#800080;">&#8216;No&#8217;</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc print</strong></span> data=hexfmt;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><img class="alignnone size-medium wp-image-2167" title="hex20_compress" src="http://thesasreference.wordpress.com/files/2009/11/hex20_compress.jpg?w=300" alt="" width="300" height="70" /></p>
<p><span style="color:#ff6600;"><strong>2. Voir les caractères hexadécimaux avec le format HEX</strong></span></p>
<p>Ici, je vous propose de voir la valeur de la variable WEBSITE au moyen de l&#8217;instruction PUT. Il est possible de voir la valeur formatée plutôt que la valeur brute en faisant suivre la variable d&#8217;un format. Le format ici sera HEXw. où w est un nombre idéalement de la longueur de la variable fois deux. En effet, les caractères hexadécimaux sont toujours de longueur deux. Si votre texte est de longueur 25, il faudra 50 caractères pour l&#8217;afficher en valeur hexadécimale.</p>
<p><span style="font-family:courier;"><strong><span style="color:#000080;">data</span></strong> hexfmt;<br />
<span style="color:#0000ff;">length</span> website $<span style="color:#008080;"><strong>25</strong></span><span style="color:#008080;"><strong></strong></span>;<br />
website=cat(<span style="color:#800080;">&#8216;20&#8242;</span>x,<span style="color:#800080;">&#8216;www.sasreference.fr&#8217;</span>,<span style="color:#800080;">&#8216;20&#8242;</span>x);<br />
<span style="color:#0000ff;">put</span> website= hex<span style="color:#008080;"><strong>50</strong></span>.;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc print</strong></span> data=hexfmt;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p>Dans le résultat qui suit, on voit donc le premier caractère de l&#8217;observation de WEBSITE a pour code 20. Le second caractère est la lettre W représentée par le code 77, et ainsi de suite.</p>
<p><img class="alignnone size-medium wp-image-2168" title="hex20_log" src="http://thesasreference.wordpress.com/files/2009/11/hex20_log.jpg?w=300" alt="" width="300" height="98" /></p>
<p><span style="color:#ff6600;"><strong>Lecture complémentaire</strong></span></p>
<ul>
<li><a title="fonction TRANWRD, valeur hexadécimale" href="http://www.sasreference.fr/2009/02/10/fonction_tranwrd/">Remplacer un mot par un autre : la fonction TRANWRD</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Créer une variable numérique à partir d'une variable caractère (fonctin INPUT avec point d'interrogation)]]></title>
<link>http://thesasreference.wordpress.com/2009/10/17/input_pointinterrogation/</link>
<pubDate>Sat, 17 Oct 2009 04:00:23 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/10/17/input_pointinterrogation/</guid>
<description><![CDATA[Vous avez des nombres et du texte sauvegardés dans une variable caractère dans une table sAS et vous]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Vous avez des nombres et du texte sauvegardés dans une variable caractère dans une table sAS et vous voulez sauvegarder les données numériques dans une variable numérique sans avoir dans la log une indication d&#8217;erreur (_ERROR_=1) pour les valeurs non compatibles. Comment adapter la fonction INPUT ?</p>
<p><span style="color:#ff6600;"><strong>1. Les données pour l&#8217;exemple</strong></span></p>
<p>Pour l&#8217;exemple,  nous avons un dataset appelé CHAR avec une variable caractère, X_CHAR et 5 observations.</p>
<p><span style="font-family:courier new;"><span style="color:#000080;"><strong>data </strong></span>char;<br />
length x_char $10;<br />
input x_char $ 1-10;<br />
datalines;<br />
-1.3<br />
- 5<br />
5.3.2<br />
18.9<br />
AB<br />
;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="color:#ff6600;"><strong>2. Le résultat attendu</strong></span></p>
<p>Nous voudrons que la première et la quatrième observation soient converties en nombre. En effet,les trois autres valeurs ne sont pas convertibles.</p>
<ul>
<li>La seconde observations est non valide à cause de l&#8217;espace séparant le signe moins et le nombre 5.</li>
<li>La troisième observation a plus d&#8217;un point</li>
<li>La dernière observation est un texte.</li>
</ul>
<p><img src="http://thesasreference.wordpress.com/files/2009/10/input_questionmark.jpg" alt="" /></p>
<p><span style="color:#ff6600;"><strong>3. La version traditionnelle</strong></span></p>
<p>La fonction INPUT permet de passer d&#8217;une variable caractère à une variable numérique. Elle est composée de deux paramètres : le nom de la variable caractère à convertir (ou une valeur entre guillemets) et l&#8217;informat qui permet d&#8217;interpréter les valeurs de la variable.</p>
<p><span style="font-family:courier new;"><span style="color:#000080;"><strong>data</strong></span> char_num;<br />
<span style="color:#0000ff;">set</span> char;<br />
x_num=<span style="color:#0000ff;">input</span>(x_char,<span style="color:#008080;">20.6</span>);<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p>Malheureusement, SAS n&#8217;est pas totalement satisfait de cette action pour les valeurs ne répondant pas aux critères de l&#8217;informat.</p>
<p><img class="alignnone size-full wp-image-2101" title="input_withoutquestionmark" src="http://thesasreference.wordpress.com/files/2009/10/input_withoutquestionmark.jpg" alt="input_withoutquestionmark" width="450" height="123" /></p>
<p><span style="color:#ff6600;"><strong>4. Une log propre grâce au point d&#8217;interrogation</strong></span></p>
<p>Le double point d&#8217;interrogation précédent le nom de l&#8217;informat empêchera la log d&#8217;avoir la note. Bien sûr, cela n&#8217;a d&#8217;intérêt que si vous avez de bonnes raisons d&#8217;ignorer ce message d&#8217;erreur. Le cas contraire, vérifiez vos données.</p>
<p><span style="font-family:courier new;"><span style="color:#000080;"><strong>data </strong></span>char_num;<br />
<span style="color:#0000ff;">set</span> char;<br />
x_num=<span style="color:#0000ff;">input</span>(x_char,??<span style="color:#008080;">20.6</span>);<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><strong><span style="color:#ff6600;">Note : </span></strong> si la fonction INPUT est utilisée dans l&#8217;option de data set WHERE, un WARNING apparaît.</p>
<p><span style="font-family:courier new;">data char_num ;<br />
set char (where=(input(x_char,20.6)=18.9));<br />
run;</span></p>
<p><img class="alignnone size-full wp-image-2140" title="input_warning" src="http://thesasreference.wordpress.com/files/2009/10/input_warning.jpg" alt="input_warning" width="450" height="111" /></p>
<p>Ce warning ne peut être enlevé avec le point d&#8217;interrogation. Il crée même une erreur dans la log.</p>
<p><img class="alignnone size-full wp-image-2141" title="input_error" src="http://thesasreference.wordpress.com/files/2009/10/input_error.jpg" alt="input_error" width="450" height="129" /></p>
<p><strong><span style="color:#ff6600;">Lecture complémentaire</span></strong></p>
<ul>
<li><a title="input fonction convertir caractère numérique" href="http://www.sasreference.fr/2008/04/21/changer_type_variable/">Créer une variable caractère en numérique et inversement</a></li>
<li><a title="sas date créer" href="http://www.sasreference.fr/2008/04/28/creer_date_sas/">Créer une date de trois manières</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Ajouter des liens hypertextes dans vos fichiers PDF]]></title>
<link>http://thesasreference.wordpress.com/2009/10/04/hyperlink_pdf/</link>
<pubDate>Sun, 04 Oct 2009 04:00:32 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/10/04/hyperlink_pdf/</guid>
<description><![CDATA[Dans cet article, je vous propose d&#8217;ajouter des liens hypertextes dans vos fichiers .PDF créés]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Dans cet article, je vous propose d&#8217;ajouter des liens hypertextes dans vos fichiers .PDF créés avec la syntaxe de l&#8217;ODS PDF. Pour illustrer ce sujet, nous créerons une table des matières (<em>table of contents</em> ou <em>TOC</em>) rustique avec ODS PDF TEXT=&#8217; &#8216;; où il suffira de cliquer sur la section qui vous intéresse pour l&#8217;atteindre.</p>
<p><span style="color:#ff6600;"><strong>1. Le principe de base</strong></span></p>
<p>Pour ajouter des liens hypertextes, il faut deux informations :</p>
<ul>
<li> la location du point d&#8217;encrage/de destination (<em>anchor</em>)</li>
<li> le lien vers ce point d&#8217;encrage</li>
</ul>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">ods</span> escapechar=<span style="color:#800080;">&#8216;^&#8217;</span>;</span></p>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">ods pdf file</span>=<span style="color:#800080;">&#8216;C:/sasref/hyperlink_toc.pdf&#8217;</span>;</span></p>
<p><span style="font-family:courier new;"> <span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8216;Table of Contents&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8221;</span>;<br />
<span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8216;^S={url=&#8217;#hommes&#8217;}1. Hommes&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8216;^S={url=&#8217;#femmes&#8217;}2. Femmes&#8217;</span>;</span></p>
<p><span style="font-family:courier new;"> <span style="color:#0000ff;">ods pdf anchor</span>=<span style="color:#800080;">&#8216;hommes&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8216;</span><span style="color:#800080;">1. Hommes&#8217;;</span><br />
<span style="color:#000080;"><strong>proc print</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class(where=(sex=<span style="color:#800080;">&#8216;M&#8217;</span>));<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier new;"> <span style="color:#0000ff;">ods pdf anchor</span>=<span style="color:#800080;">&#8216;femmes&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8216;2. Femmes&#8217;</span>;<br />
<span style="color:#000080;"><strong>proc print</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class(where=(sex=<span style="color:#800080;">&#8216;F&#8217;</span>));<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">ods pdf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><strong>Le point d&#8217;encrage</strong> : Le point d&#8217;encrage est donné par l&#8217;instruction <span style="font-family:courier new;"> <span style="color:#0000ff;">ods pdf anchor</span>=<span style="color:#800080;">&#8216;&#8230;&#8217;</span>;</span>. Entre guillemets est donné un nom de votre choix qui servira à l&#8217;identifier.</p>
<p><strong>Le lien hypertexte</strong> : Le lien vers ce point d&#8217;encrage est donné par le mot URL à préciser sous forme de style donné au texte sur lequel cliquer.</p>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8216;^S={url=&#8217;#&#8230;&#8217;}Je clique ici&#8217;</span>;</span></p>
<p><strong>Définition d&#8217;un style</strong> : Le style est défini avant le texte par S={&#8230;}. Pour indiquer à SAS qu&#8217;il faille interpréter ce texte comme un style et non un texte brut, un caractère doit précédé le tout. J&#8217;ai choisi le symbole du chapeau défini auparavant avec l&#8217;instruction <span style="font-family:courier new;"><span style="color:#0000ff;">ods</span> escapechar=<span style="color:#800080;">&#8216;^&#8217;</span>;</span></p>
<p><span style="color:#ff6600;"><strong>2. Personnaliser le style</strong></span></p>
<p><strong>Supprimer l&#8217;affichage du bookmark</strong> : Dans la version enrichie qui suit, j&#8217;ai choisi l&#8217;option NOTOC pour éviter l&#8217;affichage du bookmark sur la gauche de l&#8217;écran propre aux fichier PDF.</p>
<p><strong>Les sauts de pages à la demande</strong>: J&#8217;ai aussi choisi d&#8217;enlever par défaut tous les sauts de pages ods pdf startpage=never; puis d&#8217;ajouter une fois un saut de page entre la table des matières et les tableaux avec ods pdf startpage=now;</p>
<p><strong>Les en-têtes en moins</strong> : Le titre par défaut, la date et le numéro des pages sont enlevés :</p>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">title</span>;<br />
<span style="color:#0000ff;">options</span> nodate nonumber;</span></p>
<p><strong>Les liens hypertextes invisibles</strong> : Par défaut, le lien hypertexte est présenté par un cadre bleu autour du texte à cliquer. Pour enlever ce cadre, travaillez le style avec ACTIVELINKCOLOR, VISITEDLINKCOLOR et LINKCOLOR.</p>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8220;^S={activelinkcolor=white<br />
visitedlinkcolor=white<br />
linkcolor=white<br />
url=&#8217;&#8230;&#8217;}&#8230;&#8221;</span>;<br />
</span></p>
<p>D&#8217;autres styles permettent ici d&#8217;affiner la présentation :</p>
<ul>
<li> VJUST : ajustement vertical du texte</li>
<li> CELLHEIGHT : hauteur de la case contenant le texte</li>
<li> CELLWIDTH : largeur de la case contenant le texte</li>
<li> FONT_FACE : la police de style</li>
<li> FONT_SIZE : la taille du texte</li>
<li> INDENT : l&#8217;indentation du texte</li>
<li> FONT_WEIGHT : mise en gras du texte</li>
</ul>
<p>J&#8217;ai choisi de sauvegarder ces informations dans des macros variables pour pouvoir centraliser l&#8217;information en début de programme.</p>
<p><span style="color:#ff6600;"><strong>3. Le résultat </strong></span></p>
<p>Deux pages sont donc créées. La première contient la table des matières. Vous pouvez cliquer sur le texte <em>1. Hommes</em> ou <em>2. Femmes</em> pour rejoindre le tableau qui vous intéresse.</p>
<p><img class="alignnone size-full wp-image-2076" title="hyperlink_toc" src="http://thesasreference.wordpress.com/files/2009/10/hyperlink_toc.jpg" alt="hyperlink_toc" width="448" height="274" /></p>
<p><img class="alignnone size-full wp-image-2077" title="hyperlink_main" src="http://thesasreference.wordpress.com/files/2009/10/hyperlink_main.jpg" alt="hyperlink_main" width="448" height="277" /></p>
<p><strong><span style="color:#ff6600;">Annexe</span> : l&#8217;intégralité du code</strong></p>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">%let</span> titl=vjust=middle<br />
cellheight=30pt<br />
cellwidth=17cm<br />
font_face=arial<br />
activelinkcolor=white<br />
visitedlinkcolor=white<br />
linkcolor=white;<br />
<span style="color:#0000ff;">%let</span> titl1=&#38;titl indent=5cm font_size=16pt font_weight=bold;<br />
<span style="color:#0000ff;">%let</span> titl2=&#38;titl indent=6cm font_size=12pt;</span></p>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">title</span>;<br />
<span style="color:#0000ff;">options</span> nonumber nodate;<br />
<span style="color:#0000ff;">ods </span>escapechar=&#8217;^';</span></p>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">ods pdf file</span>=<span style="color:#800080;">&#8216;C:/sasref/hyperlink_toc.pdf&#8217;</span> notoc startpage=never;</span></p>
<p><span style="font-family:courier new;"> <span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8220;^S={&#38;titl1.}Table of Contents&#8221;</span>;<br />
<span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8221;</span>;<br />
<span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8220;^S={&#38;titl2. url=&#8217;#hommes&#8217;}1. Hommes&#8221;</span>;<br />
<span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8220;^S={&#38;titl2. url=&#8217;#femmes&#8217;}2. Femmes&#8221;</span>;</span></p>
<p><span style="font-family:courier new;"> <span style="color:#0000ff;">ods pdf</span> startpage=now;</span></p>
<p><span style="font-family:courier new;"> <span style="color:#0000ff;">ods pdf anchor</span>=<span style="color:#800080;">&#8216;hommes&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8220;^S={&#38;titl2.}1. Hommes&#8221;</span>;<br />
<span style="color:#000080;"><strong>p</strong><strong>roc print </strong></span><span style="color:#0000ff;">data</span>=sashelp.class(where=(sex=<span style="color:#800080;">&#8216;M&#8217;</span>));<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier new;"> <span style="color:#0000ff;">ods pdf anchor</span>=<span style="color:#800080;">&#8216;femmes&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf text</span>=<span style="color:#800080;">&#8220;^S={&#38;titl2.}2. Femmes&#8221;</span>;<br />
<span style="color:#000080;"><strong>proc print</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class(where=(sex=<span style="color:#800080;">&#8216;F&#8217;</span>));<br />
<span style="color:#000080;">r<strong>un</strong></span>;</span></p>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">ods pdf close;</span><br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Appeler une macro d'un catalogue permanent]]></title>
<link>http://thesasreference.wordpress.com/2009/09/27/appel_macro/</link>
<pubDate>Sun, 27 Sep 2009 04:00:17 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/09/27/appel_macro/</guid>
<description><![CDATA[Dans l&#8217;article &#8220;Sauvegarder une macro au delà d&#8217;une session&#8220;, vous avez vu c]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Dans l&#8217;article &#8220;<a title="créer macro catalog permanent" href="../2009/01/08/macro_permanent/">Sauvegarder une macro au delà d&#8217;une session</a>&#8220;, vous avez vu comment créer un catalogue permanent pour macro. Ici, je vous propose d&#8217;appeler une macro contenue dans un de ces catalogues.</p>
<p><span style="color:#ff6600;"><strong>1. Rappel : ajouter une entrée dans un catalogue pour macro</strong></span></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">libname</span> sasref <span style="color:#800080;">&#8216;C:/sasref&#8217;</span>;<br />
<span style="color:#0000ff;">options</span> sasmstore=sasref mstored;</span></p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>%macro </strong></span><strong><em>perm_macro</em></strong> /store;<br />
proc print data=sashelp.class;<br />
run;<br />
<span style="color:#000080;"><strong>%mend</strong></span> perm_macro;</span></p>
<p><span style="color:#ff6600;"><strong>2. Appeler une macro compilée</strong></span></p>
<p>Les options globales qui indique la position d&#8217;un catalogue pour macros sont MSTORED et SASMSTORE= où SASMSTORE est suivi du nom de la bibliothèque.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">libname</span> sasref &#8216;C:/sasref&#8217;;<br />
<span style="color:#0000ff;">options</span> mstored sasmstore=sasref;<br />
<em><strong>%perm_macro</strong></em>;</span></p>
<p><span style="color:#ff6600;"><strong>Lectures complémentaires</strong></span></p>
<ul>
<li><a title="créer macro catalog permanent" href="../2009/01/08/macro_permanent/">Sauvegarder une macro au delà d&#8217;une session</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Passer par un format pour changer les couleurs d'une cellule dans un tableau (PROC REPORT et ODS)]]></title>
<link>http://thesasreference.wordpress.com/2009/09/17/report_format_style/</link>
<pubDate>Thu, 17 Sep 2009 04:00:28 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/09/17/report_format_style/</guid>
<description><![CDATA[Dans de précédents articles, je vous ai parlé de la possibilité de changer le style des cellules d]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Dans de précédents articles, je vous ai parlé de la possibilité de changer le style des cellules d&#8217;un tableau. Je vous invite ici à découvrir comment un format peut vous éviter de passer par un COMPUTE/ENDCOMP de PROC REPORT pour changer le style selon les valeurs prises par une variable donnée.</p>
<p><span style="color:#ff9900;"><strong>1. Créer les formats pour l&#8217;exemple</strong></span></p>
<p>Pour mettre en gras (<em>bold</em>) ou non, il faut passer par le style <strong>FONT_WEIGHT</strong>. Dans notre exemple, ce style prendra la  valeur BOLD quand la variable AGE aura des valeurs entre 14 et 16 ans et un LIGHT pour un style non gras. Vous avez aussi à disposition la valeur MEDIUM pour un ton légèrement plus prononcé.</p>
<p>Pour changer la couleur du texte, c&#8217;est le style <strong>FOREGROUND</strong> qu&#8217;il faut utiliser. Dans notre cas, le texte aura la couleur bleu si la variable AGE est comprise entre 14 et 16 ans inclus.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc format</strong></span>;<br />
<span style="color:#0000ff;">value </span>age_font <span style="color:#008080;"><strong>11</strong></span>-<span style="color:#008080;"><strong>13</strong></span>=<span style="color:#800080;">&#8216;light&#8217;</span><br />
<span style="color:#008080;"><strong>14</strong></span>-<span style="color:#008080;"><strong>16</strong></span>=<span style="color:#800080;">&#8216;bold&#8217;</span>;<br />
<span style="color:#0000ff;">value</span> age_color <strong><span style="color:#008080;">14</span></strong>-<strong><span style="color:#008080;">16</span></strong>=<span style="color:#800080;">&#8216;blue&#8217;</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="color:#ff9900;"><strong>2. Utiliser le format dans PROC REPORT</strong></span></p>
<p>Pour changer le style d&#8217;une colonne en particulier, il suffit d&#8217;ajouter style(column)=[...] dans l&#8217;instruction DEFINE.</p>
<p>Ici au lieu de donner une couleur à toutes les valeurs avec FOREGROUND= suivi du nom de la couleur, on donne le format AGE_COLOR. qui prendra la valeur BLUE pour les AGE des 14-16 ans.</p>
<p>De manière similaire, l&#8217;épaisseur du trait est changée avec FONT_WEIGHT et le format AGE_FONT. défini auparavant.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">ods pdf file</span>=<span style="color:#800080;">&#8216;C:/sasref/zebre.pdf&#8217;</span>;<br />
<span style="color:#000080;"><strong>proc report</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class nowd;<br />
<span style="color:#0000ff;">columns</span> name age;<br />
<span style="color:#0000ff;">define</span> name / <span style="color:#0000ff;">display</span> ;<br />
<span style="color:#0000ff;">define</span> age / <span style="color:#0000ff;">display</span> style(column)=[font_weight=<span style="color:#339966;">age_font.</span> foreground=<span style="color:#339966;">age_color.</span>];<br />
<span style="color:#000080;"><strong>run;</strong></span><br />
<span style="color:#0000ff;">ods pdf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><span style="color:#ff9900;"><strong>3. Voir le résultat</strong></span></p>
<p><img class="alignnone size-full wp-image-2019" title="color_format" src="http://thesasreference.wordpress.com/files/2009/08/color_format.jpg" alt="color_format" width="330" height="231" /></p>
<p><span style="color:#ff9900;"><strong>Lectures complémentaires</strong></span></p>
<ul>
<li><a title="proc report ods style couleur" href="http://www.sasreference.fr/2009/08/30/couleurs_altenees/">Alterner les couleurs de fond dans un tableau : une ligne sur deux (PROC REPORT et ODS)</a></li>
<li><a href="http://www.sasreference.fr/2009/07/26/ods_compute/">Changer la couleur d’une ligne ou d’une colonne grâce à PROC REPORT et ODS</a></li>
<li><a href="http://www.sasreference.fr/2009/07/26/ods_compute/">Un moyen simple de changer les couleurs en fonction des valeurs prises par des variables dans un fichier .xls</a></li>
<li><a href="http://www.sasreference.fr/2008/11/21/couleurs_sas/">Choisir ses couleurs sous SAS</a></li>
</ul>
<p><span style="color:#ff6600;"><strong><span style="color:#ff9900;">Des questions ?</span> </strong></span>Envoyez votre message sur le <a title="Forum du blog la référence SAS" href="http://www.facebook.com/group.php?gid=62742793112&#38;ref=mf">forum du blog</a>.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Quelle est la différence entre un RUN et un QUIT ?]]></title>
<link>http://thesasreference.wordpress.com/2009/09/12/run_ou_quit/</link>
<pubDate>Sat, 12 Sep 2009 18:00:21 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/09/12/run_ou_quit/</guid>
<description><![CDATA[Aujourd&#8217;hui, je voulais vous parler de la différence entre les instructions RUN et QUIT.  Toby]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Aujourd&#8217;hui, je voulais vous parler de la différence entre les instructions RUN et QUIT.  Toby Dunn a écrit une <a title="sas-l forum run et quit différence" href="http://www.listserv.uga.edu/cgi-bin/wa?A2=ind0704a&#38;L=sas-l&#38;D=0&#38;P=25783">explication très bien faite sur le forum anglophone SAS-L</a>. Voici une traduction possible.</p>
<p><span style="color:#ff6600;"><strong>1. L&#8217;instruction RUN</strong></span></p>
<p>L&#8217;instruction RUN dit à SAS d&#8217;exécuter les instructions précédentes (c&#8217;est-à-dire l&#8217;étape data qui vient d&#8217;être compilée ou la procédure). C&#8217;est un délimiteur d&#8217;étape qui dit : &#8220;c&#8217;est la fin de l&#8217;étape ou de la procédure. Maintenant exécute le code.&#8221;.</p>
<p>Vous n&#8217;avez pas besoin d&#8217;utiliser l&#8217;instruction RUN, le début d&#8217;une autre étape data ou d&#8217;une procédure feront le boulot aussi. <strong>Cependant utiliser une instruction RUN nettoiera votre log</strong>.</p>
<p><span style="color:#ff6600;"><strong>2. L&#8217;instruction QUIT</strong></span></p>
<p>L&#8217;instruction QUIT est aussi un délimiteur d&#8217;étape. Quelques procédures (par exemple PROC DATASETS, PROC CATALOG) permettent de soumettre plusieurs étapes à l&#8217;intérieur d&#8217;une procédure sans avoir à terminer la procédure. Dans ces cas là, vous ajoutez une instruction RUN pour terminer une étape dans cette procédure et une instruction QUIT pour terminer la procédure.</p>
<p><span style="color:#ff6600;"><strong>3. Le cas particulier de PROC SQL</strong></span></p>
<p>SQL est un peu l&#8217;exception qui confirme la règle car cette procédure nécessite une instruction QUIT et toute instruction RUN sera ignorée. Ceci est dû au fait qu&#8217;elle exécute chaque instruction automatiquement. Il n&#8217;y a donc aucun besoin d&#8217;une exécution par groupe avec RUN mais un réel besoin d&#8217;un délimiteur de fin d&#8217;étape.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Le va-et-vient avec un fichier de transport]]></title>
<link>http://thesasreference.wordpress.com/2009/08/11/cport/</link>
<pubDate>Tue, 11 Aug 2009 04:09:45 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/08/11/cport/</guid>
<description><![CDATA[L&#8217;envoi de fichiers AS par email peut se faire au moyen de fichiers &#8220;compressés&#8221; a]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>L&#8217;envoi de fichiers AS par email peut se faire au moyen de fichiers &#8220;compressés&#8221; appelés fichiers de transport (<em>transport files</em>). Ces fichiers ont une extension .xpt. Dans cet article, vous verrez deux choses :</p>
<ul>
<li> Comment créer un fichier .xpt</li>
<li> Comment extraire les données d&#8217;un fichier .xpt</li>
</ul>
<p><span style="color:#ff6600;"><strong>1. Créer un fichier .xpt avec la procédure CPORT<br />
</strong></span></p>
<p>Dans l&#8217;exemple ci-dessous, la table CLASS de la bibliothèque SASHELP est ajoutée dans le fichier de transport SASHELP_CLASS.XPT.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">filename </span>tranfile <span style="color:#800080;">&#8216;C:/sasref/transport_files/sashelp_class.xpt&#8217;</span>;<br />
<span style="color:#000080;"><strong>proc cport</strong></span> <span style="color:#0000ff;">lib</span>=sashelp <span style="color:#0000ff;">file</span>=tranfile <span style="color:#0000ff;">memtype</span>=data;<br />
<span style="color:#0000ff;">select</span> class;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><strong>Quels fichiers envoyer ? </strong></p>
<ul>
<li><strong>LIB=</strong> : Pour ce faire, il faut préciser le nom de la bibliothèque contenant les fichiers à traiter avec LIB= : Si aucune bibliothèque n&#8217;est précisée, c&#8217;est la bibliothèque WORK qui est consultée.</li>
<li><strong>SELECT</strong> : les fichiers SAS à ajouter sont listés dans l&#8217;instruction SELECT. Si aucune instruction SELECT n&#8217;est fournie, tous les fichiers sont copiés.</li>
<li><strong> MEMTYPE=</strong> : L&#8217;option MEMTYPE restreint la sélection des fichiers aux tables SAS. Ainsi deux fichiers CLASS sont présents dans la bibliothèque SASHELP (une vue et une table) alors seule la table sera utilisée.</li>
</ul>
<p><strong>Où sauvegarder les données ? </strong>Le nom et la destination du fichier de transport sont définis dans une instruction FILENAME. Cette référence au fichier, nommée TRANFILE, est ensuite appelé par FILE=.</p>
<p><img class="alignnone size-full wp-image-1975" title="xpt" src="http://thesasreference.wordpress.com/files/2009/08/xpt.jpg" alt="xpt" width="429" height="273" /></p>
<p><span style="color:#ff6600;"><strong>2. Extraire les données d&#8217;un fichier .xpt avec la procédure CIMPORT<br />
</strong></span></p>
<p>Dans l&#8217;exemple qui suit, les données du fichier transport SASHELP_CLASS.XPT sont extraites et sauvegardées dans la bibliothèque EXTRACT.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">libname </span>extract <span style="color:#800080;">&#8216;C:/sasref/extracted_files&#8217;</span>;<br />
<span style="color:#0000ff;">filename </span>sasref <span style="color:#800080;">&#8216;C:/sasref/transport_files/sashelp_class.xpt&#8217;</span>;<br />
<span style="color:#000080;"><strong>proc cimport</strong></span> <span style="color:#0000ff;">lib</span>=extract <span style="color:#0000ff;">infile</span>=sasref;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p>Pour extraire les fichiers d&#8217;un fichier de transport, il y a l&#8217;option la procédure PROT CIMPORT.</p>
<p><strong>Quelle destination ?</strong> L&#8217;option LIB= précise la bibliothèque de destination des fichiers contenus dans le fichier de transport.</p>
<p><strong>Quelle source ? </strong>L&#8217;option INFILE= indique le nom et le chemin d&#8217;accès au fichier de transport.</p>
<p><img class="alignnone size-full wp-image-1976" title="xpt_extracted" src="http://thesasreference.wordpress.com/files/2009/08/xpt_extracted.jpg" alt="xpt_extracted" width="373" height="270" /></p>
<p><span style="color:#ff6600;"><strong>Lectures complémentaires</strong></span></p>
<p>Articles du blog</p>
<ul>
<li><a title="proc import excel" href="http://thesasreference.wordpress.com/2008/08/15/proc_import/">Passer d&#8217;un fichier de l&#8217;ODS TAGSETS.EXCELXP à un data set SAS avec PROC IMPORT</a></li>
<li><a title="proc import excel" href="http://thesasreference.wordpress.com/2009/05/24/piege_excel_getname/">Les pièges d&#8217;Excel : une colonne sans nom (GETNAMES=YES)</a></li>
<li><a title="proc import excel" href="http://thesasreference.wordpress.com/2009/05/06/piege_excel/">Les pièges d&#8217;Excel : cellules formatées</a></li>
</ul>
<p>SAS Online Doc :</p>
<ul>
<li><a href="http://support.sas.com/onlinedoc/913/getDoc/en/proc.hlp/a000055594.htm">The CPORT Procedure</a></li>
<li><a href="http://support.sas.com/onlinedoc/913/getDoc/en/hostunx.hlp/a002215218.htm">The CPORT Procedure for Unix</a></li>
<li><a href="http://support.sas.com/onlinedoc/913/getDoc/en/hostwin.hlp/win-proc-cport.htm">The CPORT Procedure for Windows</a></li>
<li><a href="http://support.sas.com/onlinedoc/913/getDoc/en/hosto390.hlp/a000165860.htm">The CPORT Procedure for z/OS</a></li>
</ul>
<ul>
<li><a href="http://support.sas.com/onlinedoc/913/getDoc/en/proc.hlp/a000055597.htm">The CIMPORT Procedure</a></li>
<li><a href="http://support.sas.com/onlinedoc/913/getDoc/en/hostunx.hlp/a002215153.htm">The CIMPORT Procedure for Unix</a></li>
<li><a href="http://support.sas.com/onlinedoc/913/getDoc/en/hostwin.hlp/win-proc-cimport.htm">The CIMPORT Procedure for Windows</a></li>
<li><a href="http://support.sas.com/onlinedoc/913/getDoc/en/hostwin.hlp/win-proc-cimport.htm">The CIMPORT Procedure for z/OS</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Indenter ses titres et pieds-de-page dans un fichier PDF]]></title>
<link>http://thesasreference.wordpress.com/2009/08/02/title_indent/</link>
<pubDate>Sun, 02 Aug 2009 04:00:20 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/08/02/title_indent/</guid>
<description><![CDATA[Comment couper ses titres et ajouter des indentations dans un fichier PDF avec SAS ? La solution deu]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Comment couper ses titres et ajouter des indentations dans un fichier PDF avec SAS ? La solution deux petits mots-clés -2n et m précédés d&#8217;un symbole défini par vous-même auparavant.</p>
<p>Notez que cette syntaxe fonctionne aussi pour les pieds-de-page.</p>
<p>Si le passage à la ligne fonction avec ODS RTF, l&#8217;indentation par contre n&#8217;est pas prise en compte.</p>
<p><span style="color:#ff6600;"><strong>1. Par défaut un titre est sur une seule ligne</strong></span></p>
<p>Dans l&#8217;exemple qui suit, un titre est donné dans une instruction TITLE.</p>
<p>Ce titre est aligné à gauche (J=L entendez par là <em>justify=left</em>).</p>
<p>Pour faciliter la lecture du programme, le titre est écrit sur plusieurs lignes. Mais au final, tout le texte apparaît sans passage à la ligne.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">title</span> j=l<br />
<span style="color:#800080;">&#8216;SASHELP.CLASS:&#8217;</span><br />
<span style="color:#800080;">&#8216;Première Variable: Nom&#8217;</span><br />
<span style="color:#800080;">&#8216;Seconde Variable: Sex&#8217;</span><br />
<span style="color:#800080;">&#8216;Troisième Variable: Age&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf file=</span><span style="color:#800080;">&#8216;C:/sasref/indent_title.pdf&#8217;</span>;<br />
<span style="color:#000080;"><strong>proc </strong><strong>print </strong></span><span style="color:#0000ff;">data</span>=sashelp.class <span style="color:#0000ff;">noobs</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;<br />
<span style="color:#0000ff;">ods pdf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;<br />
</span></p>
<p><img class="alignnone size-full wp-image-1955" title="title_01_default" src="http://thesasreference.wordpress.com/files/2009/07/title_01_default.jpg" alt="title_01_default" width="383" height="153" /></p>
<p><span style="color:#ff6600;"><strong>2. Passer à la ligne avec ODS ESCAPECHAR et ^-2n</strong></span></p>
<p>A présent, un passage à la ligne est créé avec le mot -2n.</p>
<p>Pour que SAS n&#8217;utilise par ce mot comme un texte devant apparaître dans le titre, ce mot est précédent d&#8217;un symbole de son choix (ici un chapeau) défini précédemment avec l&#8217;instruction ODS ESCAPECHAR.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods</span> escapechar=<span style="color:#800080;">&#8216;^&#8217;</span>;<br />
<span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">title</span> j=l<br />
<span style="color:#800080;">&#8216;SASHELP.CLASS:&#8217;</span><br />
<span style="color:#800080;">&#8216;^-2nPremière Variable: Nom&#8217;</span><br />
<span style="color:#800080;">&#8216;</span></span><span style="font-family:courier;"><span style="color:#800080;">^-2n</span></span><span style="font-family:courier;"><span style="color:#800080;">Seconde Variable: Sex&#8217;</span><br />
<span style="color:#800080;">&#8216;</span></span><span style="font-family:courier;"><span style="color:#800080;">^-2n</span></span><span style="font-family:courier;"><span style="color:#800080;">Troisième Variable: Age&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf file=</span><span style="color:#800080;">&#8216;C:/sasref/indent_title.pdf&#8217;</span>;<br />
<span style="color:#000080;"><strong>proc </strong><strong>print </strong></span><span style="color:#0000ff;">data</span>=sashelp.class <span style="color:#0000ff;">noobs</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;<br />
<span style="color:#0000ff;">ods pdf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><img class="alignnone size-full wp-image-1956" title="title_02_linebreak" src="http://thesasreference.wordpress.com/files/2009/07/title_02_linebreak.jpg" alt="title_02_linebreak" width="388" height="201" /></p>
<p><span style="color:#ff6600;"><strong>3. Passer à la ligne et indenter le titre avec ODS ESCAPECHAR, ^-2n et ^m</strong></span></p>
<p>A présent, l&#8217;encre ^m est ajoutée en4ème position dans la première ligne. Cela veut dire que tout le texte qui suit est indenté et débutera en position 4 sous la lettre H de SASHELP.CLASS.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods</span> escapechar=<span style="color:#800080;">&#8216;^&#8217;</span>;<br />
<span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">title</span> j=l<br />
<span style="color:#800080;">&#8216;SAS^mHELP.CLASS:&#8217;</span><br />
<span style="color:#800080;">&#8216;^-2nPremière Variable: Nom&#8217;</span><br />
<span style="color:#800080;">&#8216;</span></span><span style="font-family:courier;"><span style="color:#800080;">^-2n</span></span><span style="font-family:courier;"><span style="color:#800080;">Seconde Variable: Sex&#8217;</span><br />
<span style="color:#800080;">&#8216;</span></span><span style="font-family:courier;"><span style="color:#800080;">^-2n</span></span><span style="font-family:courier;"><span style="color:#800080;">Troisième Variable: Age&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf file=</span><span style="color:#800080;">&#8216;C:/sasref/indent_title.pdf&#8217;</span>;<br />
<span style="color:#000080;"><strong>proc </strong><strong>print </strong></span><span style="color:#0000ff;">data</span>=sashelp.class <span style="color:#0000ff;">noobs</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;<br />
<span style="color:#0000ff;">ods pdf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><img class="alignnone size-full wp-image-1957" title="title_03_indent" src="http://thesasreference.wordpress.com/files/2009/07/title_03_indent.jpg" alt="title_03_indent" width="389" height="199" /></p>
<p><strong><span style="color:#ff6600;">Lectures complémentaires</span></strong></p>
<ul>
<li><a title="ods pdf sugi" href="http://www2.sas.com/proceedings/sugi31/092-31.pdf">PDF can be Pretty Darn Fancy</a> (SUGI .pdf)</li>
<li><a title="titres et SAS" href="http://www.sasreference.fr/2008/03/28/9-points-a-savoir-sur-les-titres/">9 points pour personnaliser ses titres</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Créer des abréviations sous SAS Windows. J'adore !]]></title>
<link>http://thesasreference.wordpress.com/2009/06/28/tools_abbreviation/</link>
<pubDate>Sun, 28 Jun 2009 09:11:31 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/06/28/tools_abbreviation/</guid>
<description><![CDATA[N&#8217;avez-vous jamais eu le sentiment de devoir taper toujours un même code sous SAS avec ODS TAG]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>N&#8217;avez-vous jamais eu le sentiment de devoir taper toujours un même code sous SAS avec ODS TAGSETX.EXCELXP ou encore de ne pas vous rappeler la syntaxe exacte pour un PROC IMPORT ?</p>
<p>Une solution est de créer un programme de référence et de faire du copier/coller. Une autre solution, <strong>propre à SAS Windows</strong>, est de sauvegarder chaque code sous une abréviation et d&#8217;utiliser au moment venu cette abréviation. Voici comment cela marche.</p>
<p><span style="color:#ff6600;"><strong>1. Créer une abbréviation</strong></span></p>
<p>Pour créer un abréviation, choisissez <em>Tools/Add Abbreviation..</em>. dans le menu.</p>
<p><img class="alignnone size-full wp-image-1904" title="add_abbreviation_01" src="http://thesasreference.wordpress.com/files/2009/06/add_abbreviation_01.jpg" alt="add_abbreviation_01" width="327" height="282" /></p>
<p>Ici, je choisi de créer l&#8217;abréviation report_xls. J&#8217;ajoute par copier/coller le code propre au tagsets.excelxp dans le second champs.</p>
<p><img class="alignnone size-full wp-image-1905" title="add_abbreviation_02" src="http://thesasreference.wordpress.com/files/2009/06/add_abbreviation_02.jpg" alt="add_abbreviation_02" width="450" height="188" /></p>
<p><span style="color:#ff6600;"><strong>2. Comment utiliser l&#8217;abréviation</strong></span></p>
<p>Dans l&#8217;éditeur SAS, saisissez le nom de l&#8217;abréviation. En tapant sur entrer le mot est remplacer le texte sous-jacent.</p>
<p><span style="color:#ff6600;"><strong>3. Modifier une abréviation existante</strong></span></p>
<p>Si vous créer une nouvelle abréviation et lui donnez le même nom qu&#8217;une déjà existante, SAS vous demandera si vous souhaitez remplacer celle existante ou non.</p>
<p><img class="alignnone size-full wp-image-1906" title="add_abbreviation_03" src="http://thesasreference.wordpress.com/files/2009/06/add_abbreviation_03.jpg" alt="add_abbreviation_03" width="437" height="126" /></p>
<p><span style="color:#ff6600;"><strong>4. Visualiser les abréviations existantes et les supprimer</strong></span></p>
<p>Pour voir les abréviations existantes, aller dans le menu et choisissez<em> Tools/Keyboard Macros/Macros&#8230;</em></p>
<p><img class="alignnone size-full wp-image-1907" title="add_abbreviation_04" src="http://thesasreference.wordpress.com/files/2009/06/add_abbreviation_04.jpg" alt="add_abbreviation_04" width="441" height="284" /></p>
<p>Il ne vous reste plus qu&#8217;à sélectionner l&#8217;abréviation à supprimer et de cliquer sur <em>Delete</em>.</p>
<p><img class="alignnone size-full wp-image-1908" title="add_abbreviation_05" src="http://thesasreference.wordpress.com/files/2009/06/add_abbreviation_05.jpg" alt="add_abbreviation_05" width="432" height="316" /></p>
<p><strong>Source</strong> : <a title="SAS Windows, les abbréviations" href="http://www.pharmasug.org/content/view/132/153/">http://www.pharmasug.org/content/view/132/153</a>/</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Choisir la police de caractères pour des graphiques SAS]]></title>
<link>http://thesasreference.wordpress.com/2009/06/24/sas_font_graphic/</link>
<pubDate>Wed, 24 Jun 2009 18:29:27 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/06/24/sas_font_graphic/</guid>
<description><![CDATA[La liste des polices de caractères pour construire des graphiques sous SAS a longtemps été très limi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>La liste des polices de caractères pour construire des graphiques sous SAS a longtemps été très limitée. Depuis SAS a racheté de nouvelles polices se rapprochant des classiques comme Arial. Mais pour l&#8217;instant, voici les styles disponibles depuis de nombreuses années. La mise en image de ces polices devrait vous aider à faire un choix plus rapide.</p>
<p><span style="color:#ff6600;"><strong>1. Trois fonts avec ses variantes</strong></span></p>
<p>Ajoutez aux mots CENT, SWISS, ZAPF les lettres</p>
<ul>
<li> l pour une version comprimée,</li>
<li>x pour une version étendue/allongée,</li>
<li>b (bold) pour mettre en gras,</li>
<li>i (italic) pour mettre en italic,</li>
<li>e (empty) pour avoir un un font blanc.</li>
</ul>
<p><img class="alignnone size-full wp-image-1894" title="font_01" src="http://thesasreference.wordpress.com/files/2009/06/font_01.jpg" alt="font_01" width="450" height="299" /></p>
<p><img class="alignnone size-full wp-image-1896" title="font_02" src="http://thesasreference.wordpress.com/files/2009/06/font_02.jpg" alt="font_02" width="450" height="498" /></p>
<p><img class="alignnone size-full wp-image-1897" title="font_03" src="http://thesasreference.wordpress.com/files/2009/06/font_03.jpg" alt="font_03" width="450" height="347" /></p>
<p><strong><span style="color:#ff6600;">2. Quelques autres styles</span></strong></p>
<p>A ces trois premières polices s&#8217;ajoutent:</p>
<ul>
<li>BRUSH,</li>
<li>SIMPLEX/DUPLEX/COMPLEX/TRIPLEX,</li>
<li>SCRIPT/CSCRIPT</li>
<li>GERMAN/GITALIC/OLDENG</li>
<li>ITALIC/TITALIC</li>
</ul>
<p><img class="alignnone size-full wp-image-1898" title="font_04" src="http://thesasreference.wordpress.com/files/2009/06/font_04.jpg" alt="font_04" width="450" height="434" /></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Supprimer le texte qui sert à la création de la table des matières dans un fichier .rtf]]></title>
<link>http://thesasreference.wordpress.com/2009/06/18/notoc_data/</link>
<pubDate>Thu, 18 Jun 2009 06:06:32 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/06/18/notoc_data/</guid>
<description><![CDATA[Ici, je vous propose d&#8217;illustrer l&#8217;usage de l&#8217;option notoc_data dans l&#8217;instr]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Ici, je vous propose d&#8217;illustrer l&#8217;usage de l&#8217;option <strong>notoc_data</strong> dans l&#8217;instruction ODS RTF sous SAS. Celle-ci empêche la création des points de références nécessaires à la création d&#8217;une table des matières. En effet, ces points affectent l&#8217;affichage des tableaux sur l&#8217;écran. Comment dissimuler/supprimer ces points pour améliorer la lisibilité de vos documents RTF ?</p>
<p><strong><span style="color:#ff6600;">1. L&#8217;affichage par défaut</span></strong></p>
<p>Pour pouvoir ajouter une table des matières (<em>Table of Contents</em>, TOC) dans un document Word, des marques aux différents points de références appelés ancres (<em>anchers</em>) au fil du document doivent exister. Ces points n&#8217;apparaissent pas à l&#8217;impression.</p>
<p>Lors de la création d&#8217;un fichier .rtf par SAS, ces points de référence sont automatiquement créés. Et cela peut donner une distorsion des tableaux comme dans l&#8217;exemple ci-dessous.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods</span> <span style="color:#0000ff;">listing close</span>;<br />
<span style="color:#0000ff;">ods rtf file</span>=<span style="color:#800080;">&#8216;C:/sasref/toc.rtf&#8217;</span>;<br />
<span style="color:#000080;"><strong>proc print</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class;<br />
<span style="color:#000080;"><strong>r</strong><strong>un</strong></span>;<br />
<span style="color:#0000ff;">ods rtf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><img class="alignnone size-full wp-image-1879" title="rtf_before" src="http://thesasreference.wordpress.com/files/2009/06/rtf_before.jpg" alt="rtf_before" width="448" height="271" /></p>
<p>Avec un PROC PRINT, le point de référence ressemble à ceci :</p>
<p><span style="font-family:courier;">{tc &#8220;print&#8221; \f C \l 1}{tc &#8220;Data Set SASHELP.CLASS &#8221; \f C \l 2}</span></p>
<p>Avec un PROC REPORT, le point de référence se présente est :</p>
<p><span style="font-family:courier;">{tc &#8220;Report &#8221; \f \C \l 1}{tc &#8220;Detailed and/or summarized report &#8221; \f C \l2}</span></p>
<p>Pour palier à ce problèmes deux solutions sont envisageable.</p>
<ol>
<li>Désactiver l&#8217;affichage des symboles comme le passage à la ligne</li>
<li>Ne pas créer de points de références pour la table des matières</li>
</ol>
<p><span style="color:#ff6600;"><strong>2. Désactiver l&#8217;affichage des symboles</strong></span></p>
<p>Il suffira de cliquer sur le bouton servant à l&#8217;affichage des symboles comme le passage à la ligne, la tabulation,&#8230; pour ne plus voir les points de références utilisés si une table des matières est créée.</p>
<p><img src="http://thesasreference.wordpress.com/files/2009/06/rtf_action.jpg" alt="" /></p>
<p><span style="color:#ff6600;"><strong>3. Ne pas créer de points de référence pour la table des matières avec l&#8217;option notoc_data</strong></span></p>
<p>Il vous suffira d&#8217;ajouter l&#8217;option notoc_data dans l&#8217;instruction ODS RTF de départ pour ôter les points de référence servant pour la création d&#8217;une table des matières.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">ods rtf file</span>=<span style="color:#800080;">&#8216;C:/sasref/toc.rtf&#8217;</span> notoc_data;<br />
<span style="color:#000080;"><strong>proc print</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class;<br />
<span style="color:#000080;"><strong>run</strong></span>;<br />
<span style="color:#0000ff;">ods rtf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><img class="alignnone size-full wp-image-1882" title="rtf_after" src="http://thesasreference.wordpress.com/files/2009/06/rtf_after.jpg" alt="rtf_after" width="448" height="271" /></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Composer une page pdf avec des carrés à remplir (ODS LAYOUT/ODS REGION)]]></title>
<link>http://thesasreference.wordpress.com/2009/06/14/ods_layout_region/</link>
<pubDate>Sun, 14 Jun 2009 12:19:48 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/06/14/ods_layout_region/</guid>
<description><![CDATA[La syntaxe de l&#8217;ODS PDF sous SAS sert à la création d&#8217;un fichier au format pdf. Ici, vou]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>La syntaxe de l&#8217;ODS PDF sous SAS sert à la création d&#8217;un fichier au format pdf. Ici, vous verrez comment organiser les différents blocs de textes au moyen de ODS LAYOUT et ODS REGION. Cela sera aussi l&#8217;occasion de faire un rappel sur PROC TEMPLATE pour changer les marges d&#8217;un document et de se servir de l&#8217;instruction ODS PDF TEXT=.</p>
<p><span style="color:#ff6600;"><strong>1.Changer les valeurs par défaut</strong></span></p>
<p>Par défaut, les sorties sous SAS affichent la date, un titre et chaque page est numérotée. Pour enlever ces informations, l&#8217;instruction TITLE et les options NODATE, NONUMBER sont utilisées.</p>
<p><span style="font-family:courier;"><span style="color:#008000;">* 1. Setting;</span><br />
<span style="color:#0000ff;">options</span> nodate nonumber;<br />
<span style="color:#0000ff;">title</span>;</span></p>
<p>Par défaut, les marges des feuilles A4 ne sont pas de zéro. Pour les changer, il faut utiliser un style différent à définir dans une procéduren PROC TEMPLATE. Ici, nous créons un style appelé REPORT_PDF qui est comme le style RTF de SAS à une exception prêt : les marges du document sont de zéro centimètre.</p>
<p><span style="font-family:courier;"><span style="color:#008000;">*2. Créer le template REPORT_PDF;</span><br />
<span style="color:#000080;"><strong>proc template</strong></span>;<br />
</span><span style="font-family:courier;"><span style="color:#0000ff;">define</span> style styles.report_pdf;<br />
parent=styles.rtf;<br />
style body from Document /<br />
bottommargin = 0cm<br />
topmargin       = 0cm<br />
rightmargin   = 0cm<br />
leftmargin     = 0cm;<br />
<span style="color:#0000ff;">end</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p>Note : vous pouvez aussi choisir de rendre non défini les marges au niveau du proc template dans un premier temps. Ensuite, vous pourrez définir la valeur dans une instruction globale OPTIONS.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc template</strong></span>;<br />
</span><span style="font-family:courier;"> </span> <span style="font-family:courier;"><span style="color:#0000ff;">define</span> style styles.report_pdf;<br />
parent=styles.rtf;<br />
style body from Document /<br />
bottommargin = _undef_<br />
topmargin       = </span><span style="font-family:courier;">_undef_</span><br />
<span style="font-family:courier;"> rightmargin   = </span><span style="font-family:courier;">_undef_</span><br />
<span style="font-family:courier;"> leftmargin     = </span><span style="font-family:courier;">_undef_</span><span style="font-family:courier;">;<br />
<span style="color:#0000ff;">end</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">options</span> bottommargin=0cm topmargin=0cm rightmargin=0cm leftmargin=0cm;</span></p>
<p>Ici, j&#8217;ai choisi d&#8217;ajouter manuellement du texte au moyen de l&#8217;ODS PDF TEXT dans le fichier PDF pour illustrer l&#8217;usage d&#8217;ODS LAYOUT/ODS REGION. Au niveau de PROC TEMPLATE, il est possible de préciser la police de caractère et la taille. Ici je choisi une police Arial de taille 12pt.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc template</strong></span>;<br />
<span style="color:#0000ff;">define</span> style styles.report_pdf;<br />
parent=styles.rtf;<br />
style body from Document /<br />
bottommargin = 0cm<br />
topmargin    = 0cm<br />
rightmargin   = 0cm<br />
leftmargin     = 0cm;<br />
style usertext from usertext /<br />
font_size   = 12pt<br />
font_face   = &#8216;Arial&#8217;;<br />
<span style="color:#0000ff;">end</span>;<br />
<span style="color:#000080;"><strong>r</strong><strong>un</strong></span>;</span></p>
<p><strong><span style="color:#ff6600;">2. Créer le fichier</span></strong></p>
<p><strong>a. ODS LISTING</strong> : Stopper l&#8217;envoi dans la fenêtre OUTPUT et réactiver cette destination à la fin</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><strong>b. ODS PDF</strong> :  Envoyer les résultats à venir dans un fichier PDF, appeler le style REPORT_PDF pour ne pas utiliser le style par défaut et stopper la destination en fin de programme.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods pdf file</span>=<span style="color:#800080;">&#8216;C:/sasref/ods_layout.pdf&#8217;</span> <span style="color:#0000ff;">style</span>=report_pdf;<br />
<span style="color:#0000ff;">ods pdf close</span>;</span></p>
<p><strong>c. ODS LAYOUT</strong> : Indiquer à SAS l&#8217;endroit où ODS REGION pourra être utilisé en précisant le début de la zone avec ODS LAYOUT START et la fin avec ODS LAYOUT END .</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods</span> layout start;<br />
<span style="color:#0000ff;">ods</span> layout end;</span></p>
<p><strong>4. ODS REGION</strong> : préciser le point de départ du cadre avec X= et Y=. Puis donner la largeur (<em>width</em>) et la hauteur (<em>height</em>) du cadre.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods</span> region x=1cm y=1cm width=7cm height=2cm;<br />
<span style="color:#0000ff;">ods</span> region x=13cm y=3cm width=7cm height=2cm;<br />
<span style="color:#0000ff;">ods </span>region x=1cm y=5cm width=15cm height=1cm;<br />
<span style="color:#0000ff;">ods</span> region x=4cm y=7cm width=15cm height=19cm;</span></p>
<p><strong>Le code complète</strong></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">ods pdf file=</span><span style="color:#800080;">&#8216;C:/sasref/ods_layout.pdf&#8217;</span> <span style="color:#0000ff;">style</span>=report_pdf;<br />
<span style="color:#0000ff;">ods</span> layout start;<br />
<span style="color:#008000;">*cadre 1 : adresse expéditeur;</span><br />
<span style="color:#0000ff;">ods</span> region x=1cm y=1cm width=7cm height=2cm;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;Véronique Bourcier&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;verronique.bourcier@sasreference.fr&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf </span>text=<span style="color:#800080;">&#8216;www.sasreference.fr&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;Blog pour se former au logiciel SAS&#8217;</span>;<br />
<span style="color:#008000;">*cadre 2 : adresse destinaire + date;</span><br />
<span style="color:#0000ff;"> ods</span> region x=13cm y=3cm width=7cm height=2cm;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;Lecteurs de SAS&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;Rue des curieux&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;00000 Francophones&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=&#8217; &#8216;;<br />
<span style="color:#0000ff;"> ods pdf</span> text=<span style="color:#800080;">&#8216;14 Juin 2009, Cologne&#8217;</span>;<br />
<span style="color:#008000;">*cadre 3 : object;</span><br />
<span style="color:#0000ff;">ods</span> region x=1cm y=5cm width=15cm height=1cm;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;Objet: Exemple avec ODS LAYOUT/REGION&#8217;</span>;<br />
<span style="color:#008000;">*cadre 4 : contenu de la lettre;</span><br />
<span style="color:#0000ff;">ods</span> region x=4cm y=7cm width=15cm height=19cm;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;Madame, Monsieur&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216; &#8216;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8220;Le blog www.sasreference.fr est votre outil pour découvrir et redécouvrir la syntaxe de SAS. C&#8217;est aussi une communauté d&#8217;utilisateurs se retrouvant sur Facebook pour échanger sur de multiples thématiques :&#8221;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216; &#8216;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;+ Certification SAS&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;+ Mémoire de stage&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;+ Pharmaceutique&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;+ Banque/assurance&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;+ Milieu hospitalier&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;+ Statistiques publiques&#8217;</span>;<br />
<span style="color:#0000ff;"> ods pdf</span> text=<span style="color:#800080;">&#8216;+ Recherche&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span> text=<span style="color:#800080;">&#8216;+ Enseignement&#8217;</span>;<br />
<span style="color:#0000ff;"> ods pdf</span> text=<span style="color:#800080;">&#8216;etc. &#8216;</span>;<br />
<span style="color:#0000ff;">ods</span> layout end;<br />
<span style="color:#0000ff;">ods pdf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><span style="color:#ff6600;"><strong>3. Voir le résultat</strong></span></p>
<p><img class="alignnone size-full wp-image-1872" title="ods_layout_letter" src="http://thesasreference.wordpress.com/files/2009/06/ods_layout_letter.jpg" alt="ods_layout_letter" width="448" height="271" /></p>
<p><strong><span style="color:#ff6600;">Lectures complémentaires</span></strong></p>
<ul>
<li><a title="ods rtf margin" href="http://thesasreference.wordpress.com/2008/06/30/ods_rtf_marge/">Des marges personnalisées pour vos rapports RTF</a></li>
<li><a title="proc template proc report" href="http://thesasreference.wordpress.com/2008/06/02/debuter_proc_template_report/">Améliorer l&#8217;habillage de vos tableaux (débuter avec PROC TEMPLATE au moyen de PROC REPORT)</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Ajouter un logo dans l'en-tête des fichiers pdf/rtf]]></title>
<link>http://thesasreference.wordpress.com/2009/06/11/pdf_entete_image/</link>
<pubDate>Thu, 11 Jun 2009 10:43:13 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/06/11/pdf_entete_image/</guid>
<description><![CDATA[Des fichiers au format RTF (lisibles par word) ou PDF se créent sous SAS au moyen de la syntaxe incl]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Des fichiers au format RTF (lisibles par word) ou PDF se créent sous SAS au moyen de la syntaxe inclues l&#8217;Output Delivery System (ODS). L&#8217;en-tête et le pied de page sont ajoutés au moyen des instructions TITLE et FOOTNOTE. Ici, vous verrez quel texte mettre dans l&#8217;instruction TITLE pour ajouter une image dans l&#8217;en-tête d&#8217;un fichier PDF.</p>
<p><span style="color:#ff6600;"><strong>1. Créer un fichier PDF</strong></span></p>
<p>La table (<em>dataset</em>) CLASS de la bibliothèque SASHELP est affichée dans la sortie au moyen de l&#8217;instruction PROC PRINT.</p>
<p><strong>Les instructions ODS LISTING CLOSE/ODS LISTING</strong> : Par défaut la table est envoyée dans la fenêtre OUTPUT de SAS, souvent appelée fenêtre LISTING. Cette destination ne nous intéresse pas. Elle est désactivée le temps du PROC PRINT au moyen de l&#8217;instruction ODS LISTING CLOSE et est réactivée à la fin avec ODS LISTING.</p>
<p><strong>Les instructions ODS PDF/ODS PDF CLOSE</strong> : A la place, la première instruction ODS PDF définie le nom du fichier à créer. ODS PDF CLOSE ferme le fichier après y avoir écrit les informations du PROC PRINT.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">title</span> <span style="color:#800080;">&#8216;Mon logo&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf file</span>=<span style="color:#800080;">&#8216;C:/sasref/image_entete.pdf&#8217;</span>;<br />
<span style="color:#000080;"><strong>p</strong><strong>roc print</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class;<br />
<span style="color:#000080;"><strong>run</strong></span>;<br />
<span style="color:#0000ff;">ods pdf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><strong>L&#8217;instruction TITLE</strong> : L&#8217;instruction TITLE précède la première l&#8217;instruction ODS PDF. Si vous voulez la mettre après, je vous conseille de prendre l&#8217;habitude  d&#8217;indiquer à SAS de prendre le changement en compte en ajoutant une instruction ODS PDF juste après. Ainsi vous ferez appel à la même syntaxe avec ODS PDF et avec ODS RTF.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">ods pdf</span> <span style="color:#0000ff;">file</span>=<span style="color:#800080;">&#8216;C:/sasref/image_entete.pdf&#8217;</span>;<br />
<span style="color:#0000ff;">title</span> <span style="color:#800080;">&#8216;Mon logo&#8217;</span>;<br />
<span style="color:#0000ff;">ods pdf</span>;<br />
<span style="color:#000080;"><strong>proc print</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class;<br />
<span style="color:#000080;"><strong>run</strong></span>;<br />
<span style="color:#0000ff;">ods pdf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><strong><span style="color:#ff6600;">2. Utiliser le style pour modifier la mise en page</span></strong></p>
<p>L&#8217;image utilisée pour l&#8217;exemple est :</p>
<p><img src="http://thesasreference.wordpress.com/files/2009/06/logo.jpg" alt="" /></p>
<p>Pour changer la mise en page, il faut des styles.<strong> Les styles sont introduits par la lettre S</strong>. Afin que SAS fasse la différence entre un texte contenant la lettre S et un style, il faut faire précéder ce S d&#8217;un symbole.</p>
<p>Ici, <strong>l&#8217;accent circonflexe est choisi comme symbole précédent la lettre S</strong> pour définir un style. Pour le dire à SAS, il faut passer par l&#8217;instruction ODS ESCAPECHAR.</p>
<p>Les différents styles sont ensuite définis entre accolades.</p>
<p><span style="font-family:courier new;"><span style="color:#0000ff;">title</span> &#8220;^S={}&#8221;;</span></p>
<p>Deux styles parmi d&#8217;autres :</p>
<ul>
<li>PREIMAGE= donnera le chemin d&#8217;accès à l&#8217;image.</li>
<li>JUST= indiquera l&#8217;alignement du titre (LEFT pour la gauche, CENTER pour le milieur et RIGHT pour la droite).</li>
</ul>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods escapechar</span>=&#8217;^';<br />
<span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">title</span> <span style="color:#800080;">&#8220;^S={just=left preimage=&#8217;C:/sasref/logo.jpg&#8217;}&#8221;</span>;<br />
<span style="color:#0000ff;">ods pdf file</span>=<span style="color:#800080;">&#8216;C:/sasref/image_entete.pdf&#8217;</span>;<br />
<span style="color:#000080;"><strong>proc print</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class;<br />
<span style="color:#000080;"><strong>run</strong></span>;<br />
<span style="color:#0000ff;">ods pdf close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><span style="color:#ff6600;"><strong>Important</strong></span> :  si vous rencontrez des difficultés avec une image au format .GIF, essayez avec une image au format JPG.</p>
<p>Cette syntaxe ne fonctionne pas avec ODS TAGSETS.EXCELXP.</p>
<p><span style="color:#ff6600;"><strong>3. Voir le résultat</strong></span></p>
<p><img src="http://thesasreference.wordpress.com/files/2009/06/pdf_entete.jpg" alt="SAS, odf pdf, en-tête, image, exemple" /></p>
<p><span style="color:#ff6600;"><strong>Lectures complémentaires</strong></span></p>
<ul>
<li><a title="sas, ods rtf, numérotation pages" href="http://www.sasreference.fr/2009/01/29/ods_rtf_numerotation/">Numéroter ses pages avec ODS RTF</a></li>
<li><a title="sas, ods rtf, marges" href="http://www.sasreference.fr/2008/06/30/ods_rtf_marge/">Des marges personnalisées pour vos rapports</a></li>
<li><a title="ods rtf, proc template, introduction, proc report" href="http://thesasreference.wordpress.com/2008/06/02/debuter_proc_template_report/">Améliorer l&#8217;habillage de vos tableaux (débuter avec PROC TEMPLATE via PROC REPORT)</a></li>
<li><a title="ods rtf, saut de page" href="http://www.sasreference.fr/2008/03/19/ods_rtf_saut_page/">Structurer les sauts de page</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Plusieurs mots d'un paramètre de macro à mettre entre guillemets (%QSYSFUNC, %STR(), TRANWRD)]]></title>
<link>http://thesasreference.wordpress.com/2009/05/28/macro_parametre/</link>
<pubDate>Thu, 28 May 2009 07:35:22 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/05/28/macro_parametre/</guid>
<description><![CDATA[Mettre entre guillemets les mots contenus dans une macro variable SAS et les séparer par des virgule]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Mettre entre guillemets les mots contenus dans une macro variable SAS et les séparer par des virgules est possible au moyen des fonction %STR(), %QSYSFUNC et TRANWRD. Dans quel cas est-ce utile ? Comment se décompose cette syntaxe ?</p>
<p><strong><span style="color:#ff6600;">1. Dans quel cas a-t-on besoin d&#8217;ajouter des guillemets et virgules ?</span></strong></p>
<p>Lors de l&#8217;écriture d&#8217;une macro, vous pouvez avoir besoin d&#8217;autoriser plus d&#8217;un mot dans un des paramètres.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">options</span> mprint;</span></p>
<p><span style="color:#000080;"><strong>%</strong><strong>macro</strong></span> test (multival=);</p>
<p>&#8230;</p>
<p><span style="color:#000080;"><strong>%mend</strong></span> test;</p>
<p><em><strong>%test</strong></em> (multival=Alfred William);</p>
<p><strong>Note</strong> : l&#8217;option MPRINT de l&#8217;instruction OPTIONS permettra de voir la résolution de la macro dans la log.</p>
<p>Ensuite, le contenu de ce paramètre traité comme une macro variable peut être appelé dans une condition. Dans l&#8217;exemple qui suit <span style="font-family:courier;">&#8220;Alfred&#8221;,&#8221;William&#8221;</span> sera remplacée par la macro variable mise à jour.</p>
<p><span style="font-family:courier;"><strong><span style="color:#000080;">proc print</span></strong> data=sashelp.class (where=(name = (&#8220;Alfred&#8221;,&#8221;William&#8221;));</span></p>
<p><span style="color:#000080;"><strong>r</strong><strong>un</strong></span>;</p>
<p>Il faut pour cela mettre la macro variable à jour en ajoutant des guillemets et la virgule comme séparateur.</p>
<p><span style="color:#ff6600;"><strong>2. Comment ajouter guillemets et virgules ?</strong></span></p>
<p><strong>2.1 Un mot</strong></p>
<p>Dans le cas d&#8217;un paramètre avec un mot, on peut ajouter %str(%&#8221;) devant et derrière. Le symbole % permet d&#8217;introduire les caractères spéciaux comme le guillemet.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">%let</span> multival=<span style="color:#0000ff;">%str</span>(%&#8221;)&#38;multival.<span style="color:#0000ff;">%str</span>(%&#8221;);</span></p>
<p>La macro donne alors :</p>
<p><span style="font-family:courier;"><strong><span style="color:#000080;">%macro</span></strong> test (multival=);</span></p>
<p><span style="color:#0000ff;">%let</span> multival=<span style="color:#0000ff;">%str</span>(%&#8221;)&#38;multival.<span style="color:#0000ff;">%str</span>(%&#8221;);</p>
<p>proc print data=sashelp.class (where=(name = &#38;<span style="color:#008080;">multival.</span>));</p>
<p>run;</p>
<p><span style="color:#000080;"><strong>%mend</strong></span> test;</p>
<p><em><strong>%test</strong></em> (multival=Alfred);</p>
<p><strong>2.2 Plus d&#8217;un mot</strong></p>
<p>Pour mettre entre guillemets plus d&#8217;un mot, l&#8217;espace entre les mots sera remplacé par &#8220;,&#8221; (guillemet, virgule, guillemet) au moyen de la fonction TRANWRD.</p>
<p><span style="font-family:courier;">%qsysfunc(tranwrd(&#38;multival.,%str( ),%str(%&#8221;,%&#8221;)))</span></p>
<p>Pour exécuter cette fonction, qui n&#8217;a pas d&#8217;équivalent dans les macros fonctions, il faut englober le tout dans %SYSFUNC/%QSYSFUNC. La présence de la virgule oblige dans notre cas à utiliser %QSYSFUNC.</p>
<p><span style="font-family:courier;"><strong><span style="color:#000080;">%macro</span></strong> test (multival=);</span></p>
<p><span style="color:#0000ff;">%let</span> multival=%str(%&#8221;)%qsysfunc(tranwrd(&#38;multival.,%str( ),%str(%&#8221;,%&#8221;)))%str(%&#8221;);</p>
<p>proc print data=sashelp.class (where=(name in (&#38;<span style="color:#008080;">multival.</span>));</p>
<p>run;</p>
<p><span style="color:#000080;"><strong>%mend</strong></span> test;</p>
<p><em><strong>%test</strong></em> (multival=Alfred William);</p>
<p><strong>2.3 Plus d&#8217;un mot mis en majuscule</strong></p>
<p>Enfin, pour ne pas tenir compte de la case, le texte peut être mis en majuscule au moyen de la fonction %UPCASE.</p>
<p><span style="font-family:courier;">where=(upcase(name) in (<span style="color:#0000ff;">%upcase</span>(&#38;<span style="color:#008080;">multival.</span>))</span></p>
<p>Cela donne :</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>%macro</strong></span> test (multival=);</span></p>
<p><span style="color:#0000ff;">%let</span> multival=<span style="color:#0000ff;">%str</span>(%&#8221;)<span style="color:#0000ff;">%qsysfunc</span>(tranwrd(&#38;multival.,<span style="color:#0000ff;">%str</span>( ),<span style="color:#0000ff;">%str</span>(%&#8221;,%&#8221;)))<span style="color:#0000ff;">%str</span>(%&#8221;);</p>
<p>proc print data=sashelp.class (where=(upcase(name) in (<span style="color:#0000ff;">%upcase</span>(&#38;<span style="color:#008080;">multival.</span>))));</p>
<p>run;</p>
<p><span style="color:#000080;"><strong>%mend</strong></span> test;</p>
<p><em><strong>%test</strong></em> (multival=Alfred William);</p>
<p><strong><span style="color:#ff6600;">Lectures complémentaires</span></strong></p>
<ul>
<li><a href="http://www.sasreference.fr/category/les-fontions/sysfunc-fontions/">Autres usages de la fonction %SYSFUNC</a></li>
<li><a href="http://www.sasreference.fr/category/les-fontions/tranwrd/">Autres usages de la fonction TRANWRD</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Mini-quiz SAS en ligne (J-11)]]></title>
<link>http://thesasreference.wordpress.com/2009/05/14/quiz/</link>
<pubDate>Thu, 14 May 2009 06:15:44 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/05/14/quiz/</guid>
<description><![CDATA[Sébastien Ringuedé a rédigé des questions du type Certification SAS Base. Ces questions sont en fran]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Sébastien Ringuedé a rédigé des questions du type Certification SAS Base. Ces <strong>questions sont en français.</strong> Comme pour la certification, il a mis en place un système proposant de manière &#8220;aléatoire&#8221; 70  de ces questions. Vous qvez deux heures pour y répondre.</p>
<p style="text-align:center;"><strong>Le lundi 25 mai 2009, quiz SAS en ligne</strong><br />
(débutez ce test de 2h entre 20h30 et 21h30 heure de Paris)</p>
<p>Deux exemplaires de son livre sur SAS sont <strong>à gagner</strong> :</p>
<p style="text-align:center;"><a href="http://www.amazon.fr/gp/product/2744073318?ie=UTF8&#38;tag=lrs06-21&#38;linkCode=as2&#38;camp=1642&#38;creative=6746&#38;creativeASIN=2744073318">SAS Introduction au décisionnel : méthode et maîtrise du langage</a></p>
<p>Pour plus d&#8217;informations, reportez-vous au site : <a href="http://www.sas-sr.com/viewtopic.php?id=175">http://www.sas-sr.com/viewtopic.php?id=175</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Récupérer la valeur d'une option système dans une macro variable, %SYSFUNC(GETOPTION())]]></title>
<link>http://thesasreference.wordpress.com/2009/04/30/sysfunc_getoption/</link>
<pubDate>Thu, 30 Apr 2009 05:53:43 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/04/30/sysfunc_getoption/</guid>
<description><![CDATA[Les options SAS modifiables au moyen de l&#8217;instruction globale OPTIONS peuvent être retrouvées ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Les options SAS modifiables au moyen de l&#8217;instruction globale OPTIONS peuvent être retrouvées dans une étape data ou autre au moyen de %SYSFUNC(GETOPTION()).</p>
<p>Par exemple, cette semaine, j&#8217;ai eu besoin de savoir combien de caractères par ligne je pouvais entrer dans ma sortie (fenêtre OUTPUT). En d&#8217;autres termes, je voulais connaître la LINESIZE et en fonction d&#8217;elle ajuster les colonnes de mon listing généré au moyen d&#8217;un simple PROC REPORT.</p>
<p><strong><span style="color:#ff6600;">1. Lire dans la LOG l&#8217;information</span></strong></p>
<p>L&#8217;instruction PROC OPTIONS permet de lister toutes les options dans la fenêtre LOG de SAS. En ajoutant OPTION=, l&#8217;affichage est réduit à la seule option LINESIZE.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc options</strong></span> <span style="color:#0000ff;">option</span>=linesize;<br />
<strong><span style="color:#000080;">run</span></strong>;</span></p>
<p>Dans notre exemple, l&#8217;option LINESIZE est de 91. Jusqu&#8217;à 91 caractères pourront être affichés sur une même ligne avec un PROC PRINT ou autre.</p>
<p><span style="font-family:courier;">LINESIZE=91 Line size for SAS log and SAS procedure output<br />
<span style="color:#0000ff;">NOTE: PROCEDURE OPTIONS used (Total process time):<br />
real time 0.00 seconds<br />
cpu time 0.00 seconds</span></span></p>
<p><span style="color:#ff6600;"><strong>2. Sauvegarder l&#8217;information dans une macro variable</strong></span></p>
<p>Pour illustrer la syntaxe %SYSFUNC(GETOPTION()), je choisi de sauvegarder l&#8217;information dans une macro variable appelée CURRENT_LS. Cette valeur est ensuite affichée dans la LOG au moyen de l&#8217;instruction %PUT.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">%let</span> current_ls<span style="color:#0000ff;">=%sysfunc</span>(getoption(linesize));<br />
<span style="color:#0000ff;">%put</span> &#38;current_ls.;</span></p>
<p>Vous pouvez directement inclure %SYSFUNC(GETOPTION()), dans une instruction globale comme TITLE si vous le souhaitez.</p>
<p>La liste des options du système SAS est grande. A vous d&#8217;explorer les possibilités que vous offre cette notation.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Changer la longueur d'une variable avec PROC SQL (instruction ALTER)]]></title>
<link>http://thesasreference.wordpress.com/2009/04/27/proc_sql_alter/</link>
<pubDate>Mon, 27 Apr 2009 18:40:25 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/04/27/proc_sql_alter/</guid>
<description><![CDATA[En SAS, l&#8217;instruction ALTER de PROC SQL a la capacité de changer le libellé d&#8217;un data se]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>En SAS, l&#8217;instruction ALTER de PROC SQL a la capacité de changer le libellé d&#8217;un data set, modifier le format/informat ou le libellé d&#8217;une variable. Mais son principale intérêt réside dans sa capacité à modifier la longueur d&#8217;une variable caractère sans changer la position de la variable dans le data set.</p>
<p><strong><span style="color:#ff6600;">1. Comparaison avec deux autres méthodes : PROC DATASETS et l&#8217;étape DATA</span></strong></p>
<p>Alors que PROC DATASETS permet de modifier le format/informat, le libellé d&#8217;une variable ou de renommer une variable, il ne permet pas de changer la longueur d&#8217;une variable.</p>
<p>Avec une simple étape data, il est possible de modifier la longueur de la variable en ajoutant une instruction LENGTH avant de lire les donnees avec un SET/MERGE&#8230; Mais la séquence d&#8217;affichage des variables n&#8217;est plus respecté. Il faut soit avoir sauvegardé au préalable l&#8217;ordre d&#8217;affichage (ou l&#8217;entrer manuellement, bof !), soit utiliser l&#8217;instruction ALTER de PROC SQL&#8230;</p>
<p><strong><span style="color:#ff6600;">2. Quelques données pour tester soi-même</span></strong></p>
<p><span style="font-family:courier;"><span style="color:#008000;">* Create two formats SEX and GENDER;</span><br />
<span style="color:#000080;"><strong>proc format</strong></span>;<br />
<span style="color:#0000ff;">value</span> $ sex <span style="color:#800080;">&#8216;M&#8217;</span>=<span style="color:#800080;">&#8216;Male&#8217;<br />
</span><span style="color:#800080;">&#8216;F&#8217;</span>=<span style="color:#800080;">&#8216;Female&#8217;</span>;<br />
<span style="color:#0000ff;">value</span> $ gender &#8216;<span style="color:#800080;">M&#8217;</span>=<span style="color:#800080;">&#8216;Homme&#8217;<br />
</span><span style="color:#800080;">&#8216;F&#8217;</span>=<span style="color:#800080;">&#8216;Femme&#8217;</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier;"><span style="color:#008000;">*Create a data set named CLASS ;<br />
*based on the SASHELP.CLASS data set ;<br />
*adding the SEX format to the SEX variable;</span><br />
<span style="color:#000080;"><strong>data</strong></span> class;<br />
<span style="color:#0000ff;">set</span> sashelp.class;<br />
<span style="color:#0000ff;">format</span> sex <span style="color:#008080;">sex.</span>;<br />
<strong>run</strong>;</span></p>
<p><span style="color:#ff6600;"><strong>3. L&#8217;instruction ALTER pour modifier la longueur d&#8217;une variable</strong></span></p>
<p>Dans l&#8217;instruction ALTER de PROC SQL, le mot-clé MODIFY introduit deux variables SEX et NAME à modifier.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc sql</strong></span>;<br />
<span style="color:#000080;">alter</span> <span style="color:#000080;">table </span>class (<span style="color:#000080;">label</span>=<span style="color:#800080;">&#8216;Changes with PROC SQL and ALTER&#8217;</span>)<br />
<span style="color:#000080;">modify</span> sex <span style="color:#000080;">format</span>=<span style="color:#008080;">$gender.</span>,<br />
name <span style="color:#000080;">char</span>(<span style="color:#008080;"><strong>20</strong></span>) <span style="color:#000080;">label</span>=<span style="color:#800080;">&#8216;Student Name&#8217;</span>;<br />
<span style="color:#000080;"><strong>quit</strong></span>;</span></p>
<p><strong>Changement le plus intéressant</strong> :</p>
<ul>
<li>La longueur de la variable caractère NAME est à l&#8217;origine 8. Elle est remplacée par 20.</li>
</ul>
<p>Quelques changements secondaires :</p>
<ul>
<li>Libellé de data set : Dans l&#8217;exemple ci-dessus le data set CLASS a pour libellé &#8216;Changes with PROC SQL and ALTER&#8217;.</li>
<li>format de variable : Le format de la variable SEX est à l&#8217;origine $SEX. Il est ici remplacé par le format $GENDER.</li>
<li>Libellé de variabel : Le libellé de la variable NAME est ajouté. Il s&#8217;agit de &#8216;Student Name&#8217;.</li>
</ul>
<p><strong>A retenir</strong> :</p>
<ol>
<li><strong>Seules les variables caractères</strong> peuvent avoir leur longueur changées au moyen de l&#8217;instruction ALTER.</li>
<li>Cette instruction permet certe de modifier le format d&#8217;un data set. Néanmoins, elle ne permet pas de supprimer tous les formats d&#8217;un data set.</li>
</ol>
<p><span style="color:#ff6600;"><strong>Lectures complementaires</strong> :</span></p>
<ul>
<li><a title="sas, proc datasets, modify" href="http://thesasreference.wordpress.com/2009/03/05/proc_datasets_modify/">Modifier un data set sans le lire (formater, renommer, libeller)</a></li>
<li><a title="sas, ordre variables" href="http://thesasreference.wordpress.com/2008/04/07/variables_ordre_affichage/">Changer la sequence d&#8217;affichage des variables</a></li>
<li><a title="sas, proc sql, debutant" href="http://thesasreference.wordpress.com/2008/09/18/proc_sql_debutant/">4 etapes de base pour creer un data set avec PROC SQL</a></li>
</ul>
<p><span style="color:#ff6600;"><strong>SAS Online DOC</strong></span></p>
<ul>
<li><a title="SAS online doc, proc sql" href="http://support.sas.com/onlinedoc/913/getDoc/fr/proc.hlp/a000086336.htm">The SQL Procedure</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Parler français : représenter un nombre 100 987,24]]></title>
<link>http://thesasreference.wordpress.com/2009/04/18/fonction_comma/</link>
<pubDate>Sat, 18 Apr 2009 07:00:20 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/04/18/fonction_comma/</guid>
<description><![CDATA[Selon le pays les nombres sont présentés de manière différente. COMMA et COMMAX sont deux formats ut]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Selon le pays les nombres sont présentés de manière différente. COMMA et COMMAX sont deux formats utilisés par SAS pour représentés les nombres mais ne s&#8217;applique pas au cas français. Vous verrez donc comment créer le format qui vous convient avec l&#8217;instruction PICTURE de PROC FORMAT.</p>
<p><strong><span style="color:#ff6600;">1. La différence français/anglais</span></strong></p>
<p>Les francophones présentent les nombres différemment des anglophones sur deux points.</p>
<ul>
<li><strong>Les milliers</strong> : Les chiffres des milliers sont séparés par un espace alors que les américains utilisent la virgule</li>
<li><strong>Les décimales</strong> : Les décimales sont séparées par une virgule en français contre un point en anglais</li>
</ul>
<p><strong><span style="color:#ff6600;">2. La représentation par défaut de SAS</span></strong></p>
<p>Par défaut, les nombres sous SAS sont simplifiés comme sur une calculatrice.</p>
<ul>
<li><strong>Les milliers</strong> : le seul séparateur est celui des décimales</li>
<li><strong>Les décimales</strong> : le point fait office de séparateur pour les décimales</li>
</ul>
<p>Pour une présentation à l&#8217;anglais, il faudra appliquer le format COMMA. Il n&#8217;existe à ma connaissance qu&#8217;une semi version française : le format COMMAX. En effet celui-ci utilise bien la virgule pour séparer les entiers des décimales mais il utilise aussi le point et non le blanc pour séparer les milliers. On préférera donc créer un format avec l&#8217;instruction PICTURE.</p>
<p><strong><span style="color:#ff6600;">2. Un exemple</span></strong></p>
<p><strong>Créer un format</strong> : dans le cas présent, les nombres seont affichés jusqu&#8217;à 999999,99,  en ajoutant un espace entre les milliers et un virgule pour les décimales.</p>
<ul>
<li><strong>L&#8217;usage du 0 </strong>: il n&#8217;y aura pas de zéro affiché à l&#8217;avant du nombre si celui-ci est plus petit que 100000.</li>
<li><strong>L&#8217;usage du 9</strong> : Les décimales s&#8217;afficheront toujours avec deux chiffres après la virgules même si le second chiffre est un zéro.</li>
</ul>
<p><span style="font-family:courier;"><strong><span style="color:#000080;">proc format</span></strong>;<br />
<span style="color:#0000ff;">picture</span> commafr other=&#8217;000 000,99&#8242;;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><strong>Appliquer les formats COMMA,  COMMAX et format personnel<br />
</strong></p>
<p>Dans cette étape data trois variables sont créées chacune avec une observation.</p>
<p>Dans les trois cas, un format avec une extension 9.2 est ajouté de manière permanente. On indique à SAS que le nombre ne dépassera normalement pas 9 caractères dont 2 pour les décimales.</p>
<p><span style="font-family:courier;"><strong><span style="color:#000080;">data</span></strong> fr_en;<br />
<span style="color:#0000ff;">format</span> </span><span style="font-family:courier;">eg_english comma<strong><span style="color:#008080;">9.2</span></strong><br />
</span><span style="font-family:courier;"> eg_semifrench commax<strong><span style="color:#008080;">9.2</span></strong><br />
eg_french commafr<strong><span style="color:#008080;">9.2</span></strong>;<br />
</span><span style="font-family:courier;">eg_english=100987.24;<br />
eg_semi_french=100987.24;<br />
eg_french=100987.24;<br />
<strong><span style="color:#000080;">run</span></strong>;</span></p>
<p><strong>Voir le résultat</strong></p>
<p><span style="font-family:courier;"> eg_english   eg_semifrench   eg_french<br />
</span></p>
<p><span style="font-family:courier;">100,987.24     100.987,24    100 987,24<br />
</span></p>
<p>La variable EG_ENGLISH (exemple, anglais) reçoit, quant à elle, un format COMMA9.2 pour un affichage à l&#8217;américaine/l&#8217;anglais.</p>
<p>La variable EG_SEMIFRENCH (exemple,respectant partiellement la syntaxe française) reçoit u nformat COMMAX9.2.</p>
<p>La variable EG_FRENCH (exemple, français) reçoit le format créé manuellement COMMAFR9.2 pour un affichage avec un blanc entre chaque groupe de trois chiffres parmi dans la partie entière et deux chiffres pour la partie décimale.</p>
<p><span style="color:#ff6600;"><strong>Lectures complémentaires</strong></span></p>
<ul>
<li><a title="sas, heure, français, proc format, picture, datetime" href="http://thesasreference.wordpress.com/2009/03/16/parler_francais_heure/">Parler français : les heures sous la forme 9h30</a></li>
<li><a title="sas, arrondir, format, round" href="http://thesasreference.wordpress.com/2008/03/31/arrondi_format/">Arrondir ses chiffres avant d&#8217;appliquer un format</a></li>
<li><a title="sas, proc format, picture, sysfunc" href="http://thesasreference.wordpress.com/2009/03/12/sysfunc_date/">Ajouter une date dans un nom de fichier Word, Excel,&#8230;</a></li>
<li><a title="sas, heure, proc format" href="http://thesasreference.wordpress.com/2008/10/24/time_format/">Afficher 7h30 du matin sous la forme 07:30</a></li>
</ul>
<p><span style="color:#ff6600;"><strong>SAS Online Doc</strong></span></p>
<ul>
<li><a title="sas online doc, comma format" href="http://support.sas.com/onlinedoc/913/getDoc/fr/lrdict.hlp/a000200667.htm">COMMAw.d Format</a></li>
<li><a title="sas online doc, commax format" href="http://support.sas.com/onlinedoc/913/getDoc/fr/lrdict.hlp/a000200667.htm">COMMAXw.d Format</a></li>
<li><a title="sas online doc, picture statement" href="http://support.sas.com/onlinedoc/913/getDoc/fr/proc.hlp/a002473467.htm">PICTURE Statement</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Les anniversaires, cela se fête avec SAS]]></title>
<link>http://thesasreference.wordpress.com/2009/04/02/anniversaire_musique_sas/</link>
<pubDate>Thu, 02 Apr 2009 19:46:47 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/04/02/anniversaire_musique_sas/</guid>
<description><![CDATA[Aujourd&#8217;hui étant mon anniversaire, je fais la paresseuse et vous communique un petit fichier ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Aujourd&#8217;hui étant mon anniversaire, je fais la paresseuse et vous communique un petit fichier SAS, reçu ce jour (merci Alex), à faire tourner sous Windows, écouteurs en place, pour la prochaine fois qu&#8217;un collègue ou pote qui connaît SAS soufflera ses bougies. Amusez-vous bien !</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">%let</span> pc=1;</span></p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>%macro</strong></span> sasreference_fr(note,octave,length);</span></p>
<p><span style="font-family:courier;"> select(&#38;note.);<br />
when (&#8216;A&#8217;)   call sound  (55*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;A#&#8217;) call sound (58*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;Bb&#8217;) call sound (58*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;B&#8217;)   call sound  (62*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;C&#8217;)   call sound  (65*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;C#&#8217;) call sound (69*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;Db&#8217;) call sound (69*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;D&#8217;)   call sound  (73.5*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;D#&#8217;) call sound (73.5*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;Eb&#8217;) call sound (78*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;E&#8217;)   call sound  (82*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;F&#8217;)   call sound  (87*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;F#&#8217;) call sound (92.5*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;Gb&#8217;) call sound (92.5*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;G&#8217;)   call sound  (98*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;G#&#8217;) call sound (104*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;Ab&#8217;) call sound (104*(2**&#38;octave.),&#38;length.*160*&#38;pc.);<br />
when (&#8216;R&#8217;)   call sleep((&#38;length./3)*&#38;pc.,1);<br />
otherwise;<br />
end;<br />
<strong><span style="color:#000080;"> %mend</span></strong> sasreference_fr;</span></p>
<p><span style="font-family:courier;"><strong><span style="color:#000080;">data</span></strong> <span style="color:#0000ff;">_null_</span>;<br />
%sasreference_fr(&#8216;C&#8217;,3,1);<br />
%sasreference_fr(&#8216;C&#8217;,3,1);<br />
%sasreference_fr(&#8216;D&#8217;,3,2);<br />
%sasreference_fr(&#8216;C&#8217;,3,2);<br />
%sasreference_fr(&#8216;F&#8217;,3,2);<br />
%sasreference_fr(&#8216;E&#8217;,3,4);</span></p>
<p><span style="font-family:courier;"> %sasreference_fr(&#8216;R&#8217;,3,2);</span></p>
<p><span style="font-family:courier;"> %sasreference_fr(&#8216;C&#8217;,3,1);<br />
%sasreference_fr(&#8216;C&#8217;,3,1);<br />
%sasreference_fr(&#8216;D&#8217;,3,2);<br />
%sasreference_fr(&#8216;C&#8217;,3,2);<br />
%sasreference_fr(&#8216;G&#8217;,3,2);<br />
%sasreference_fr(&#8216;F&#8217;,3,4);</span></p>
<p><span style="font-family:courier;"> %sasreference_fr(&#8216;R&#8217;,3,2);</span></p>
<p><span style="font-family:courier;"> %sasreference_fr(&#8216;C&#8217;,3,1);<br />
%sasreference_fr(&#8216;C&#8217;,3,1);<br />
%sasreference_fr(&#8216;C&#8217;,4,2);<br />
%sasreference_fr(&#8216;A&#8217;,4,2);<br />
%sasreference_fr(&#8216;F&#8217;,3,1);<br />
%sasreference_fr(&#8216;F&#8217;,3,1);<br />
%sasreference_fr(&#8216;E&#8217;,3,2);<br />
%sasreference_fr(&#8216;D&#8217;,3,4);</span></p>
<p><span style="font-family:courier;"> %sasreference_fr(&#8216;R&#8217;,3,2);</span></p>
<p><span style="font-family:courier;"> %sasreference_fr(&#8216;Bb&#8217;,4,1);<br />
%sasreference_fr(&#8216;Bb&#8217;,4,1);<br />
%sasreference_fr(&#8216;A&#8217;,4,2);<br />
%sasreference_fr(&#8216;F&#8217;,3,2);<br />
%sasreference_fr(&#8216;G&#8217;,3,2);<br />
%sasreference_fr(&#8216;F&#8217;,3,4);<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p>Pour les curieux, je vous invite à consulter les programmes des chansons suivantes sur <a title="sas musique" href="http://www.developpez.net/forums/d511269/bases-donnees/business-intelligence/sas/sas-musique/">www.developpez.com</a> :</p>
<ul>
<li> <a title="sas, musique, deep purple" href="http://www.conf-intimes.1k.fr/SAS/DEEP_PURPLE_-_SMOKE_ON_THE_WATER.sas">Deep Purple, Smoke on the Water</a></li>
<li> <a title="sas, musique, chapeaux ronds" href="http://www.conf-intimes.1k.fr/SAS/Ils_ont_des_chapeaux_ronds_,_vive_les_bretons.sas">Ils ont des chapeaux ronds</a></li>
<li> <a title="sas, musique, old mac donald had a farm" href="http://www.conf-intimes.1k.fr/SAS/Old_Mc_Donald_Had_A_Farm.sas">Old Mac Donald had a Farm</a></li>
<li> <a title="sas, musique, stratovarius" href="http://www.conf-intimes.1k.fr/SAS/STRATOVARIUS.sas">Stratovarius</a></li>
<li> <a title="sas, musique, red hot chili pepper, around the world" href="http://www.conf-intimes.1k.fr/SAS/Red_hot_chili_peppers_-_around_the_world_intro.sas">Red Hot Chili Pepper, Around the World (intro)</a></li>
<li> <a title="sas, musique MacGyver" href="http://www.conf-intimes.1k.fr/SAS/MACGYVER.sas">Mac Gyver, générique</a></li>
<li> <a title="sas, musique, mario theme" href="http://www.conf-intimes.1k.fr/SAS/MARIO.sas">Mario Theme</a></li>
<li> <a title="sas, musique, bonhomme mousse" href="http://www.conf-intimes.1k.fr/SAS/le%20petit%20bonhomme%20en%20mousse.sas">Le petit bonhomme en mousse</a></li>
</ul>
<p>Les plus téméraires s&#8217;intéresserons à la publication &#8220;<a title="sas, music" href="http://www2.sas.com/proceedings/sugi29/048-29.pdf">Making Music in SAS</a>&#8220;. Vos créations pourront être publiées sur le blog.</p>
<p><span style="color:#ff6600;"><strong>A lire aussi</strong></span> <a href="http://www.sasreference.fr">www.sasreference.fr</a> :</p>
<ul>
<li><a title="sas, case, when, condition" href="http://thesasreference.wordpress.com/2008/07/03/condition_sql_case_when/"> Penser conditionnel (3/3) : Case When</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Mettre à jour une table SAS à partir des métadonnées]]></title>
<link>http://thesasreference.wordpress.com/2009/03/30/metadata/</link>
<pubDate>Mon, 30 Mar 2009 04:00:15 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/03/30/metadata/</guid>
<description><![CDATA[Les métadonnées (metadata) peuvent se présenter sous la forme de tables SAS (data sets). Elles donne]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Les métadonnées (<em>metadata)</em> peuvent se présenter sous la forme de tables SAS (<em>data sets</em>). Elles donnent une description d&#8217;une table SAS.</p>
<p>Si un data set existe déjà, vous pouvez retrouver des métadonnées dans le dictionnaire COLUMNS ou avec un PROC CONTENTS : nom de variable, position, type, longueur, format, etc.</p>
<p>Mais ce qui est intéressant est de préparer ce descriptif à l&#8217;avance pour créer ou actualiser un jeu de données.</p>
<p>Ici, nous verrons comment définir des métadonnées et les appliquer sur un data set existant.</p>
<p><strong><span style="color:#ff6600;">1. Créer un data set de base pour l&#8217;exemple</span></strong></p>
<p>Le data set AE contient la variable SASREF qui prend la valeur 1.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>data</strong></span> ae;<br />
   sasref=1;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc contents</strong></span> <span style="color:#0000ff;">data</span>=ae <span style="color:#0000ff;">varnum</span>;<br />
<strong><span style="color:#000080;">run</span></strong>;</span></p>
<p><img class="alignnone size-full wp-image-1499" title="meta_first1" src="http://thesasreference.wordpress.com/files/2009/03/meta_first1.jpg" alt="meta_first1" width="401" height="152" /></p>
<p><span style="color:#ff6600;"><strong>2. Créer les métadonnées pour l&#8217;exemple</strong></span></p>
<p>Le data set contenant les métadonnées est composé de six variables :</p>
<ul>
<li>La position des variables (MYVARNUM)</li>
<li>Le nom des variables (MYNAME)</li>
<li>Leur libellé (MYLABEL)</li>
<li>Leur type (numérique ou alphanumérique) (MYTYPE)</li>
<li>La longueur des variables (MYLENGTH)</li>
<li>Leur format (MYFORMAT)</li>
</ul>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>data</strong></span> meta_ae;<br />
   <span style="color:#0000ff;">length</span> myvarnum <span style="color:#008080;"><strong>8</strong></span> myname $<strong><span style="color:#008080;">8</span></strong> mylabel $<span style="color:#008080;"><strong>14</strong></span> mytype $<span style="color:#008080;"><strong>1</strong></span> mylength <span style="color:#008080;"><strong>8</strong></span> myformat $<span style="color:#008080;"><strong>11</strong></span>;<br />
   <span style="color:#0000ff;">input</span> myvarnum myname mylabel <span style="color:#008080;"><strong>12</strong></span>-<span style="color:#008080;"><strong>25</strong></span> mytype mylength myformat;<br />
   <span style="color:#0000ff;">datalines</span>;<br />
1 SUJECTID Subject Number C 10 10.<br />
2 RECID    Record ID      N 8 10.<br />
3 AETERM   Term           C 60 60.<br />
4 AE_SD    Starting Day   N 8 2.<br />
5 AE_SM    Starting Month N 8 2.<br />
6 AE_SY    Starting Year  N 8 4.<br />
7 AE_SDAT  Starting Date  N 8 DATE9.<br />
8 AESEV    Severity       N 8 AESEV.<br />
;<br />
<strong><span style="color:#000080;">run</span></strong>;</span></p>
<p><span style="color:#ff6600;"><strong>3. Créer le format AESEV pour l&#8217;exemple</strong></span></p>
<p>Dans les métadonnées, le format AESEV s&#8217;applique à la variable sur la gravité (<em>severity</em>) de l&#8217;effet secondaire (<em>adverse event</em>).</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc format</strong></span>;<br />
   <span style="color:#0000ff;">value</span> aesev 1=<span style="color:#800080;">&#8216;Severe&#8217;</span><br />
               2=<span style="color:#800080;">&#8216;Mild&#8217;</span>;<br />
<strong><span style="color:#000080;">run</span></strong>;</span></p>
<p><span style="color:#ff6600;"><strong>4. Objectif</strong></span></p>
<p>Le but est de construire une étape data où les instructions ATTRIB sont listées avant de lire les données de AE. Ces ATTRIB servent à définir les variables du data set AE dans l&#8217;ordre indiqué par MYVARNUM dans les métadonnées avec leur libellé, type, longueur et format.</p>
<p>De plus, seules les variables listées dans les métadonnées seront gardées. La variable SASREF devra disparaître.</p>
<p><img class="alignnone size-full wp-image-1501" title="meta_fileprint" src="http://thesasreference.wordpress.com/files/2009/03/meta_fileprint.jpg" alt="meta_fileprint" width="426" height="358" /></p>
<p><span style="color:#ff6600;"><strong>5. Lister les variables à garder dans une macro variable</strong></span></p>
<p>Afin de ne garder que les variables présentent dans les métadonnées, une liste en est faite. Elle est sauvegardée dans la macro variable MYNAME_LST. Cette liste sera ensuite appelée dans une option KEEP=.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc sql</strong></span> <span style="color:#0000ff;">noprint</span>;<br />
   <span style="color:#0000ff;">select</span> <span style="color:#0000ff;">distinct</span> myname <span style="color:#0000ff;">into</span> : myname_lst <span style="color:#0000ff;">separated by</span> <span style="color:#800080;">&#8216; &#8216;</span><br />
   <span style="color:#0000ff;">from</span> meta_ae;<br />
<strong><span style="color:#000080;">quit</span></strong>;</span></p>
<p><span style="color:#ff6600;"><strong>6. Générer le programme</strong></span></p>
<p>Le programme est généré au moyen d&#8217;un DATA _NULL_.</p>
<p><strong>Un tri préalable des métadonnées :</strong> L&#8217;ordre dans lequel les instructions ATTRIB seront listées affectera l&#8217;ordre d&#8217;apparition des variables. L&#8217;instruction PROC SORT s&#8217;assure que ces instructions apparaîtront dans l&#8217;ordre donnée dans les métadonnées par la variable MYVARNUM.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc sort</strong></span> <span style="color:#0000ff;">data</span>=meta_ae;<br />
   <span style="color:#0000ff;">by</span> myvarnum;<br />
<strong><span style="color:#000080;">run</span></strong>;</span></p>
<p><strong>Un catalogue pour écrire le programme</strong> : J&#8217;ai choisi ici de sauvegarder le programme généré dans un catalogue pointé dans l&#8217;étape data sous le nom SASREF. Ce nom est précédemment défini au moyen de l&#8217;instruction FILENAME.</p>
<p>Après exécution du programme (%INCLUDE),</p>
<ul>
<li>le FILENAME désignant ce catalogue est désactivé (instruction FILENAME) et</li>
<li>le catalogue lui-même est supprimé (PROC DATASETS).</li>
</ul>
<p>Vous pouvez choisir d&#8217;utiliser un simple nom de fichier à supprimer ensuite manuellement ou avec une commande Unix/Windows (cf instruction FILENAME en vert).</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">filename</span> sasref <span style="color:#0000ff;">catalog</span> <span style="color:#800080;">&#8216;work.sasref.meta.source&#8217;</span>;<br />
<span style="color:#008000;">*filename sasref &#8216;C:/sasref/attrib_meta.sas&#8217;</span>;</span></p>
<p>L&#8217;activation de l&#8217;instruction *FILE PRINT; à la place de FILE SASREF vous permettra de voir votre code dans la fenêtre OUTPUT lors du développement du code.</p>
<p><strong>Des outils optionnels</strong> : Les arobases @ et +(-1) sont simplement là pour l&#8217;apparence du programme mais n&#8217;affecte en aucun cas l&#8217;exécution du code. Ils sont donc optionnels.</p>
<ul>
<li>Les arobases font débuter le texte à la position donnée par le nombre qui suit.</li>
<li>Les +(-1) permettent de revenir d&#8217;une position en arrière avant de continuer à taper le texte. Ainsi le blanc créé automatiquement avec PUT  n&#8217;existe plus.</li>
</ul>
<p><strong>Distinguer les variables numériques des variables alphanumériques</strong> : Un symbole dollar $ est obligatoire pour définir la longueur et le format des variables. Il est donc de faire varier le texte en fonction du type (variable MYTYPE=N ou C).</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>data</strong></span> _null_;<br />
   <span style="color:#0000ff;">set</span> meta_ae end=eof;<br />
   <span style="color:#008000;">*file print</span>;<br />
   <span style="color:#0000ff;">file</span> sasref;<br />
   <span style="color:#0000ff;">if</span> _N_=<span style="color:#339966;"><strong>1</strong></span> <span style="color:#0000ff;">then put</span> <span style="color:#800080;">&#8216;data ae (keep= &#38;myname_lst.);&#8217;</span>;<br />
   <span style="color:#0000ff;">put</span> @<strong><span style="color:#339966;">4</span></strong> <span style="color:#800080;">&#8216;attrib &#8216;</span> myname @<strong><span style="color:#339966;">23</span></strong> <span style="color:#800080;">&#8220;label = &#8216;&#8221;</span> mylabel +(-<span style="color:#339966;"><strong>1</strong></span>)<span style="color:#800080;"> &#8220;&#8216;&#8221;</span> ;<br />
   <span style="color:#0000ff;">if</span> mytype=<span style="color:#800080;">&#8216;N&#8217;</span> <span style="color:#0000ff;">then<br />
      do</span>;<br />
         <span style="color:#0000ff;">put</span> @<span style="color:#339966;"><strong>23</strong></span> <span style="color:#800080;">&#8216;length = &#8216;</span> mylength;<br />
         <span style="color:#0000ff;">put</span> @<span style="color:#339966;"><strong>23</strong></span> <span style="color:#800080;">&#8216;format = &#8216;</span> myformat +(-<span style="color:#339966;"><strong>1</strong></span>)&#8217;;';<br />
      <span style="color:#0000ff;">end</span>;<br />
   <span style="color:#0000ff;">else if</span> mytype=<span style="color:#800080;">&#8216;C&#8217;</span> <span style="color:#0000ff;">then<br />
      do</span>;<br />
         <span style="color:#0000ff;">put</span> @<span style="color:#339966;"><strong>23</strong></span> <span style="color:#800080;">&#8216;length = $&#8217;</span> mylength;<br />
         <span style="color:#0000ff;">put</span> @<span style="color:#339966;"><strong>23</strong></span> <span style="color:#800080;">&#8216;format = $&#8217;</span> myformat +(-<span style="color:#339966;"><strong>1</strong></span>) &#8216;;&#8217;;<br />
      <span style="color:#0000ff;">end</span>;<br />
   <span style="color:#0000ff;">if</span> eof <span style="color:#0000ff;">then<br />
      do</span>;<br />
         <span style="color:#0000ff;">put</span> @<span style="color:#339966;"><strong>3</strong></span> <span style="color:#800080;">&#8217;set ae;&#8217;</span>;<br />
         <span style="color:#0000ff;">put</span> <span style="color:#800080;">&#8216;run;&#8217;</span>;<br />
      <span style="color:#0000ff;">end</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">%include</span> sasref;<br />
<span style="color:#0000ff;">filename</span> sasref;</span></p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc datasets </strong></span><span style="color:#0000ff;">memtype</span>=catalog ;<br />
   <span style="color:#0000ff;">delete</span> sasref;<br />
<strong><span style="color:#000080;">run</span></strong>;</span></p>
<p><span style="color:#ff6600;"><strong>7. Le résultat</strong></span></p>
<p>Au final, le data set AE contient les variables listées dans les métadonnées et seulement ces variable</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc contents</strong></span> <span style="color:#0000ff;">data</span>=ae <span style="color:#0000ff;">varnum</span>;<br />
<strong><span style="color:#000080;">run</span></strong>;</span></p>
<p><img class="alignnone size-full wp-image-1500" title="meta_next" src="http://thesasreference.wordpress.com/files/2009/03/meta_next.jpg" alt="meta_next" width="450" height="204" /></p>
<p><strong><span style="color:#ff6600;">Lectures complémentaires</span> </strong>:</p>
<ul>
<li><a title="dictionnaires SAS proc sql" href="http://www.sasreference.fr/2008/10/01/sas_dictionary/">Les deux dictionnaires SAS les plus utilisés : TABLES et COLUMNS </a></li>
<li><a title="sas data _null_" href="http://www.sasreference.fr/2008/12/04/data_null/">Créer un fichier .sas automatiquement</a></li>
<li><a title="sas variable ordre séquence" href="http://www.sasreference.fr/2008/04/07/variables_ordre_affichage/">Changer la séquence d&#8217;affichage des variables</a></li>
<li><a title="sas instruction put" href="http://thesasreference.wordpress.com/2008/02/24/ecrire-un-texte-avec-linstruction-put/">Ecrire un texte avec l&#8217;instruction PUT</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Parler français : les heures sous la forme 9h30]]></title>
<link>http://thesasreference.wordpress.com/2009/03/16/parler_francais_heure/</link>
<pubDate>Mon, 16 Mar 2009 04:00:32 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/03/16/parler_francais_heure/</guid>
<description><![CDATA[Je vous propose une série d&#8217;articles sur la thématique &#8220;Parler français avec SAS&#8221;.]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Je vous propose une série d&#8217;articles sur la thématique &#8220;Parler français avec SAS&#8221;. Je reprend les notions du précédent article sur les heures pour nous intéresser à la manière d&#8217;ajouter la lettre h séparant habituellement les heures des minutes ? Voici un exemple structuré en 4 parties.</p>
<p><strong><span style="color:#ff6600;">1. L&#8217;instruction PICTURE de PROC FORMAT</span></strong></p>
<p>Ici est créé un format HR_FR au moyant de l&#8217;instruction PICTURE dans une procédure PROC FORMAT. Il s&#8217;applique à des données exprimant les heures SAS.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc format</strong></span>;<br />
<span style="color:#0000ff;">picture</span> hr_fr other=<span style="color:#800080;">&#8216;%Hh%0M&#8217; </span>(<span style="color:#0000ff;">datatype</span>=time);<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><strong><span style="color:#ff6600;">2. Créer un data set pour illustrer le sujet</span></strong></p>
<p>L&#8217;étape data crée un data set HEURE_FR contenant une variable DEBUT avec deux observations. Ces records sont des heures exprimées en <em>SAS Time</em>.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>data</strong></span> heure_fr;<br />
debut=<span style="color:#800080;">&#8216;9:05&#8242;</span>t;<br />
<span style="color:#0000ff;">output</span>;<br />
debut=<span style="color:#800080;">&#8216;14:05&#8242;</span>t;<br />
<span style="color:#0000ff;">output</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="color:#ff6600;"><strong>3. Appliquer le format HR_FR à la variable DEBUT</strong></span></p>
<p>Le temps de la procédure PROC PRINT est ajouté le format HR_FR à la variable DEBUT .</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc print</strong></span> <span style="color:#0000ff;">data</span>=heure_fr;<br />
<span style="color:#0000ff;">format</span> debut <span style="color:#008080;"><strong>hr_fr.</strong></span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><strong><span style="color:#ff6600;">4. Voir Le résultat de la procédure PROC PRINT</span></strong></p>
<p><span style="font-family:courier;">debut<br />
</span><span style="font-family:courier;">9h05<br />
14h05</span></p>
<p><span style="color:#ff6600;"><strong>Lectures complémentaires</strong></span> :</p>
<ul>
<li><a title="sas, time, sysfunc" href="http://thesasreference.wordpress.com/2009/03/12/sysfunc_date/">Ajouter une date dans un nom de fichier Excel, Word, etc.</a></li>
<li><a title="sas, time, format, picture" href="http://www.sasreference.fr/2008/10/24/time_format/">Afficher 7h30 sous la forme 07:30</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Ajouter une date dans un nom de fichier Excel, Word...]]></title>
<link>http://thesasreference.wordpress.com/2009/03/12/sysfunc_date/</link>
<pubDate>Thu, 12 Mar 2009 04:00:53 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/03/12/sysfunc_date/</guid>
<description><![CDATA[Sous SAS, en créant un fichier .xls ou .rtf avec la syntaxe de l&#8217;ODS (Output Delivery System),]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Sous SAS, en créant un fichier .xls ou .rtf avec la syntaxe de l&#8217;ODS (<em>Output Delivery System</em>), il est parfois pratique d&#8217;ajouter dans le nom du fichier une date. Par exemple : listing_20090311.xls.</p>
<p>Nous verrons ici plusieurs représentations de la date et de l&#8217;heure : afin d&#8217;avoir des noms triables par ordre chronologique, l&#8217;année apparaît avant le mois et le jour.</p>
<p>La syntaxe proposée, %SYSFUNC(fonction, format), s&#8217;utilise dans d&#8217;autres cas que la définition d&#8217;un nom de fichier (.rtf, .xls, &#8230;). De manière générale, elle sert à utiliser des fonctions en dehors d&#8217;une étape data ou d&#8217;une procédure. Par exemple, elle peut être ajoutée dans une instruction TITLE.</p>
<p><span style="color:#ff6600;"><strong>1. L&#8217;objectif pour un programme exécuté le 11 mars 2009<br />
</strong></span></p>
<p>L&#8217;objectif de l&#8217;exemple qui suit est d&#8217;obtenir un fichier .xls nommé class_20090311.xls dont la date change selon le jour de sa création.</p>
<p>La version fixe se présente ainsi : un fichier .xls est créé au moyen de ODS TAGSETS.EXCELXP. Il contient les données du data set SASHELP.CLASS. La création d&#8217;un fichier dans la fenêtre OUTPUT est suspendu le temps de la création du fichier .xls au moyen de l&#8217;instruction ODS LISTING CLOSE et ODS LISTING.</p>
<pre><span style="color:#0000ff;">ods listing close</span>;
<span style="color:#0000ff;">ods tagsets.excelxp</span> <span style="color:#0000ff;">file</span>=<span style="color:#800080;">'C:/sasref/class_20090311.xls'</span>;
<strong><span style="color:#000080;">proc print </span></strong><span style="color:#0000ff;">data</span>=sashelp.class;
<strong><span style="color:#000080;">run</span></strong>;
<span style="color:#0000ff;">ods tagsets.excelxp close</span>;
<span style="color:#0000ff;">ods listing</span>;</pre>
<p><span style="color:#ff6600;"><strong>2. Ajouter de la flexibilité avec %SYSFUNC</strong></span></p>
<p>A présent, la date est définie automatiquement au moyen de la macro fonction %SYSFUNC. Cette fonction est dans ce cas particulier composée de deux paramètres :</p>
<ul>
<li>la date SAS extraite au moins de la fonction TODAY()</li>
<li>le format à appliquer sur cette date</li>
</ul>
<p><strong>Résoudre le contenu de la fonction %SYSFUNC grâce aux guillemets doubles</strong> : la fonction %SYSFUNC fait partie du langage macro. Dès lors, pour obtenir la résolution de son contenu, il faut utiliser des guillemets doubles.</p>
<p><strong>Retrouver la date d&#8217;exécution du programme grâce aux fonctions TODAY() ou DATE () :</strong> La fonction TODAY() retourne la date SAS d&#8217;exécution du programme. Une alternative est la fonction DATE(). Dans les deux cas, la fonction ne contient pas de paramètre.</p>
<p><strong>Le format YYMMDDn. pour écrire 20090311</strong> : Le format YYMMDDn. est un sous-ensemble de la fonction YYMMDD composée de 8 caractères, sauf indication contraire, faisant apparaître :</p>
<ul>
<li>l&#8217;année en premier,</li>
<li>suivi du mois en chiffre et</li>
<li>enfin du jour.</li>
</ul>
<p>Ce format avec l&#8217;extension &#8220;n&#8221; a la particularité de ne pas utiliser de symbole ou espace séparatant le jour, du mois et de l&#8217;année. Les 8 caractères par défaut de la fonction laisse de la place à une année exprimée par 4 chiffres.</p>
<pre><span style="color:#0000ff;">ods listing close</span>;
<span style="color:#0000ff;">ods <span style="color:#000000;">tagsets.excelxp</span> file</span>=<span style="color:#800080;">"C:/sasref/class_%sysfunc(today(),yymmddn.).xls"</span>;
<span style="color:#000080;"><strong>proc print</strong> </span><span style="color:#0000ff;">data</span>=sashelp.class;
<span style="color:#000080;"><strong>run</strong></span>;
<span style="color:#0000ff;">ods <span style="color:#000000;">tagsets.excelxp</span> close;</span>
<span style="color:#0000ff;">ods listing</span>;</pre>
<p><span style="color:#ff6600;"><strong>3. Tester d&#8217;autres formes d&#8217;affichage</strong></span></p>
<p><strong>3.1 Ajouter des tirets bas entre le jour, le mois et l&#8217;année grâce à la fonction TRANSLATE</strong></p>
<p><strong>class_2009_03_11.xls</strong> : pour avoir des tirets bas (underscore) entre le jour, le mois et l&#8217;année, il n&#8217;existe pas de format directement applicable. Une solution est alors d&#8217;utilise un autre symbole et de le remplacer avec la fonction TRANSLATE.</p>
<p>Ici le format YYMMDD10 retourne une date de la forme 20009-03-11. Les traits d&#8217;union (hyphen) sont remplacés par des tirets bas (underscore).</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods <span style="color:#000000;">tagsets.excelxp</span> file</span>=<span style="color:#800080;">&#8220;C:/sasref/class_%sysfunc(translate(%sysfunc(today(),yymmdd10.),&#8217;_',&#8217;-')).xls&#8221;</span>;</span></p>
<p><strong>3.2 Ajouter une heure avec TIME() et PICTURE (</strong><strong>class_20090311_113057.xls)</strong></p>
<p><strong>Quelle fonction pour l&#8217;heure </strong><strong>? </strong>: La fonction TIME() retourne l&#8217;heure sous la forme d&#8217;un time SAS.</p>
<p><strong>Quels formats </strong><strong>pour l&#8217;heure ? </strong>: Le format HHMM. retournera les heures et les minutes, tandis que le format TIME. retournera en plus les secondes. Dans les deux cas cependant, les heures avant 10h apparaissent avec seulement un chiffre : 9:30 et non 09:30. Un espace remplace le zéro manquant.</p>
<p>L&#8217;instruction PICTURE de PROC FORMAT pour un format personalisé : Une solution est de créer un format personalisé au moyen de l&#8217;instruction PICTURE (<em>PICTURE statement</em>). Comme les lettres H, M et S n&#8217;inclus pas de zéro devant (<em>leading zero</em>) pour les nombres à un chiffres, il faut les ajouter dans l&#8217;instruction PICTURE.</p>
<p><strong>Note</strong> : %0S fait référence aux secondes. Il n&#8217;est obligatoire que si vous voulez des secondes dans votre texte final.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc format</strong></span>;<br />
   <span style="color:#0000ff;">picture</span> sasref other=<span style="color:#800080;">&#8216;%0H%0M%0S&#8217; </span>(<span style="color:#0000ff;">datatype</span>=time);<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p>Ensuite, </p>
<ul>
<li>pour une heure à quatre chiffres (heure + minutes) , il faudra préciser le nombre 4 dans l&#8217;appel du format.</li>
<li>pour une heures à six chiffres (heures + minutes + secondes), c&#8217;est 6 qui doit être ajouté</li>
</ul>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods <span style="color:#000000;">tagsets.excelxp</span> file</span>=<span style="color:#800080;">&#8220;C:/sasref/class_%sysfunc(today(),yymmddn.)_%sysfunc(time(),sasref6.).xls&#8221;</span>;</span></p>
<p><span style="color:#ff6600;"><strong>Lectures complémentaires sur www.sasreference.fr<br />
</strong></span></p>
<p>ODS</p>
<ul>
<li><a title="sas, ods, tagsets, excelxp" href="http://thesasreference.wordpress.com/2008/05/12/ods_tagsets_excelxp_1/">Mes premiers pas avec ODS TAGSETS.EXCELXP</a> (Partie 1/3)</li>
<li><a title="sas, ods, tagsets, excelxp" href="http://www.sasreference.fr/2008/05/19/ods_tagsets_excelxp_2/">Mes premiers pas avec ODS TAGSETS.EXCELXP</a> (Partie 2/3)</li>
<li><a title="sas, ods, tagsets, excelxp" href="http://thesasreference.wordpress.com/2008/05/26/ods_tagsets_excelxp_3/">Mes premiers pas avec ODS TAGSETS.EXCELXP</a> (Parite 3/3)</li>
</ul>
<p>Les fonctions</p>
<ul>
<li><a title="sas, translate, fonction" href="http://www.sasreference.fr/2009/02/23/caracteres_ascii/">Enlever certains caractères spéciaux avec la fonction TRANSLATE</a></li>
</ul>
<p>Les formats :</p>
<ul>
<li><a title="sas format picture" href="http://www.sasreference.fr/2008/10/24/time_format/">Afficher 7h30 sous la forme 07:30</a></li>
</ul>
<p>Les macros fonctions</p>
<ul>
<li><a href="http://www.sasreference.fr/2009/01/15/eval_macro_fonction/">Additionner deux macros variables : la fonction %EVAL</a> (usage de %SYSFUNC)<a href="http://www.sasreference.fr/2009/01/15/eval_macro_fonction/"><br />
</a></li>
<li><a title="sas, sysfunc" href="http://www.sasreference.fr/2008/04/14/compter_obs/">Combien d&#8217;observations dans mon data set</a> (usage de %SYSFUNC)</li>
</ul>
<p><strong><span style="color:#ff6600;">SAS Online Doc</span></strong></p>
<p>%SYSFUNC</p>
<ul>
<li><a title="sas, sysfunc, fonction" href="http://support.sas.com/onlinedoc/913/getDoc/de/mcrolref.hlp/z3514sysfunc.htm">%SYSFUNC and %QSYSFUNC Functions</a></li>
<li>%SYSFUNC : <a title="sas, sysfunc" href="http://support.sas.com/onlinedoc/913/getDoc/de/mcrolref.hlp/a001962663.htm">Summary Descriptions and Syntax</a></li>
</ul>
<p><a title="sas, format" href="http://support.sas.com/onlinedoc/913/getDoc/de/lrdict.hlp/a001263753.htm">Formats sorted by Categories</a> (inclus : Date and Time)</p>
<ul>
<li><a title="sas format" href="http://support.sas.com/onlinedoc/913/getDoc/de/lrdict.hlp/a000197961.htm">YYMMDDw.</a></li>
<li><a title="sas, format, yymmdd" href="http://support.sas.com/onlinedoc/913/getDoc/de/lrdict.hlp/a000589916.htm">YYMMDDwx.</a></li>
<li><a title="sas, format, hhmm" href="http://support.sas.com/onlinedoc/913/getDoc/de/lrdict.hlp/a000198049.htm">HHMMw.d</a></li>
<li><a title="sas, format, time" href="http://support.sas.com/onlinedoc/913/getDoc/de/lrdict.hlp/a000197928.htm">TIMEw.d</a></li>
</ul>
<p>Format et PICTURE</p>
<ul>
<li><a title="sas proc format picture" href="http://support.sas.com/onlinedoc/913/getDoc/fr/proc.hlp/a002473467.htm">Picture Statement</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Gérer les long titres (et pieds-de-page) insérés dans une feuille de calcul (ODS TAGSETS.EXCELXP)]]></title>
<link>http://thesasreference.wordpress.com/2009/07/17/long_titre_odstagsetsexcelxp/</link>
<pubDate>Fri, 17 Jul 2009 04:00:21 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/07/17/long_titre_odstagsetsexcelxp/</guid>
<description><![CDATA[Aujourd&#8217;hui je vous propose quelques options pour travailler l&#8217;affichage de longs titres]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Aujourd&#8217;hui je vous propose quelques options pour travailler l&#8217;affichage de longs titres et pieds-de-pages qui sont insérés dans une feuille de calcul. Cela complètera les articles <a title="titre et pieds de page dans feuille de calcul avec embedded_titles et embedded_footnotes" href="http://www.sasreference.fr/2009/07/09/tagsets_xls_titre/">Ajouter les titres et pieds-de-page dans une feuille de calcul</a> (EMBEDDED_TITLES=, EMBEDDED_FOOTNOTES= et l&#8217;option ajoutée lors de la mise à jour de l&#8217;article SKIP_SPACE=) et <a title="proc template en combinaison avec ods tagsets.excelxp pour personnaliser ses titres" href="http://www.sasreference.fr/2009/07/14/title_template/">Personnaliser l&#8217;apparence des titres et des pieds-de-page dans un fichier .xls (ODS TAGSETS.EXCELXP et PROC TEMPLATE)</a>.</p>
<p>Je vais continuer à utiliser le style XLS_TITL pour les couleurs, polices, etc. proposé dans le précédent article pour mes captures d&#8217;écran.</p>
<p><span style="color:#ff6600;"><strong>1. Par défaut, un titre partiellement visible<br />
</strong></span></p>
<p>Lorsqu&#8217;un titre est plus long que la largeur fournie par les colonnes du tableau affiché, seule une partie du titre est visible.</p>
<p><img title="03_xls_title" src="../files/2009/07/03_xls_title1.jpg" alt="03_xls_title" width="426" height="133" /></p>
<p><strong><span style="color:#ff6600;">2. Une solution valable seulement sur les anciennes versions de TAGSETS.EXCELXP</span></strong></p>
<p>Une solution est d&#8217;utiliser la place disponible par les autres cellules. L&#8217;instruction global OPTIONS NOCENTER suffira. Mais cette fonctionnalité ne fonctionne pas avec les dernières mises à jour de TAGSETS.EXCELXP.</p>
<p><strong><span style="color:#ff6600;">3. Agrandir la hauteur de la ligne</span></strong></p>
<p>Pour agrandir la hauteur de la ligne, il vous faudra utiliser l&#8217;option <strong>ROWS_HEIGHTS=</strong> composée de 7 nombres. Les quatrième et cinquième nombres font respectivement référence à la hauteur des lignes pour les titres et la hauteur des lignes pour les pieds-de-page.</p>
<p>Par défaut, on a: ROWS_HEIGHTS=&#8217;0,0,0,0,0,0,0&#8242;.</p>
<p>En appliquant cette option à notre exemple, cela donne : ROW_HEIGHTS=&#8217;0,0,0,45,40,0,0&#8242;.</p>
<p><img class="alignnone size-full wp-image-1934" title="04_xls_title" src="http://thesasreference.wordpress.com/files/2009/07/04_xls_title.jpg" alt="04_xls_title" width="381" height="139" /></p>
<p><span style="color:#ff6600;"><strong>4. Le code pour l&#8217;exemple</strong></span></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">ods</span> tagsets.excelxp <span style="color:#0000ff;">file</span>=<span style="color:#800080;">&#8216;C:/sasref/class.xls&#8217;</span> <span style="color:#008000;">/*style=xls_titl*/</span><br />
options(embedded_titles=<span style="color:#800080;">&#8216;yes&#8217;</span><br />
embedded_footnotes=<span style="color:#800080;">&#8216;yes&#8217;</span><br />
row_heights=&#8217;0,0,0,45,40,0,0&#8242;);</span></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">title</span> <span style="color:#800080;">&#8216;Titre sur 2 lignes&#8217;</span>;<br />
<span style="color:#0000ff;">footnote </span><span style="color:#800080;">&#8216;Pied-de-page sur 2 lignes&#8217;</span>;<br />
<span style="color:#0000ff;">ods</span> tagsets.excelxp;</span></p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc report</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class nowd;<br />
<span style="color:#0000ff;">columns</span> name age;<br />
<span style="color:#0000ff;">defin</span>e name/<span style="color:#0000ff;">display</span> <span style="color:#800080;">&#8216;Nom&#8217;</span>;<br />
<span style="color:#0000ff;">define</span> age /<span style="color:#0000ff;">display</span> <span style="color:#800080;">&#8216;Age&#8217;</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods</span> tagsets.excelxp <span style="color:#0000ff;">close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p><strong><span style="color:#ff6600;">Lectures complémentaires</span></strong></p>
<ul>
<li><a title="ods tagsets.excelxp, title, footnote, proc template, style" href="http://www.sasreference.fr/2009/07/14/title_template/">Personnaliser l&#8217;apparence des titres et pieds-de-page dans un fichier .xls (ODS TAGSETS.EXCELXP et PROC TEMPLATE)</a></li>
<li><a title="couleur sas" href="http://www.sasreference.fr/2008/11/21/couleurs_sas/">Choisir ses couleurs sous SAS</a></li>
<li><a title="ods tagsets excelxp titre pied de page embedded_titles embedded_footnotes" href="http://www.sasreference.fr/2009/07/09/tagsets_xls_titre/">Ajouter les titres et pieds-de-page dans un fichier .xls</a></li>
<li><a title="instruction title sous sas" href="../2008/03/28/9-points-a-savoir-sur-les-titres/">9 points pour personnaliser ses titres</a></li>
<li><a href="../2009/06/01/ods_tagsets_excelxp/">En-tête et pied-de-page avec TAGSETX.EXCELXP</a> (print_header et print_footer)</li>
<li><a title="débuter avec ods tagsets excelxp" href="../2008/05/12/ods_tagsets_excelxp_1/">Mes premiers pas avec ODS TAGSETX.EXCELXP (1/3)</a></li>
<li><a title="débuter avec ods tagsets excelxp" href="../2008/05/19/ods_tagsets_excelxp_2/">Mes premiers pas avec ODS TAGSETX.EXCELXP (2/3)</a></li>
<li><a title="ods tagsets excelxp débuter" href="../2008/05/26/ods_tagsets_excelxp_3/">Mes premiers pas avec ODS TAGSETS.EXCELXP (3/3)</a></li>
<li><a title="mise à jour tagsets excelxp" href="../2009/06/04/tagsets_excelxp_update/">Mettre à jour ses TAGSETS pour EXCELXP</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Personnaliser l'apparence des titres et pieds-de-page dans un fichier.xls (ODS TAGSETS.EXCELXP et PROC TEMPLATE)]]></title>
<link>http://thesasreference.wordpress.com/2009/07/14/title_template/</link>
<pubDate>Tue, 14 Jul 2009 06:19:00 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/07/14/title_template/</guid>
<description><![CDATA[Après vous avoir présenté les options EMBEDDED_TITLES et EMBEDDED_FOOTNOTES dans l&#8217;article : A]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Après vous avoir présenté les options EMBEDDED_TITLES et EMBEDDED_FOOTNOTES dans l&#8217;article : <a title="ods tagsets excelxp titre pied de page embedded_titles embedded_footnotes" href="http://www.sasreference.fr/2009/07/09/tagsets_xls_titre/">Ajouter les titres et pieds-de-page dans une feuille de calcul du fichier .xls</a>, je vous propose de personnaliser l&#8217;apparence de vos titres au moyen d&#8217;un nouveau style créé dans une instruction PROC TEMPLATE.</p>
<p><span style="color:#ff6600;"><strong>1. Créer un style personnaliser pour ses titres et pieds de page</strong></span></p>
<p>Le nouveau style s&#8217;appelle XLS_TITL. Comme base, nous prenons un style existant sous SAS : STYLES.DEFAULT et faisont quelques modification au niveau des titres et pieds-de-page.</p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc template</strong></span>;<br />
<span style="color:#0000ff;">define</span> style styles.xls_titl;<br />
parent=styles.rtf;</span></p>
<p><span style="font-family:courier;"><span style="color:#ff0000;">style</span> systemtitle from systemtitle /<br />
background=transparent<br />
foreground=#<span style="color:#008080;"><strong>0</strong><strong>00000</strong></span><br />
font_style=roman<br />
font_weight = medium<br />
font_size=<span style="color:#008080;"><strong>18</strong></span>pt<br />
font_face=<span style="color:#800080;">&#8216;Arial&#8217;</span>;</span></p>
<p><span style="font-family:courier;"><span style="color:#ff0000;">style</span> systemfooter from systemfooter/<br />
background=transparent<br />
foreground=#<span style="color:#008080;"><strong>000000</strong></span><br />
font_style=roman<br />
font_weight = medium<br />
font_size=<span style="color:#008080;"><strong>14</strong></span>pt<br />
font_face=<span style="color:#800080;">&#8216;Arial&#8217;</span>;</span></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">end</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<ul>
<li><strong>BACKGROUND</strong> modifie la couleur de font des cellules (voir l&#8217;article : <a title="couleur sas" href="    * 9 points pour personnaliser ses titres     * En-tête et pied-de-page avec TAGSETX.EXCELXP (print_header et print_footer)     * Mes premiers pas avec ODS TAGSETX.EXCELXP (1/3)     * Mes premiers pas avec ODS TAGSETX.EXCELXP (2/3)     * Mes premiers pas avec ODS TAGSETS.EXCELXP (3/3)     * Mettre à jour ses TAGSETS pour EXCELXP">choisir ses couleurs sous SAS</a>). Notez que le mot TRANSPARENT ne fonctionne pas avec la version 1.86 de TAGSETS.EXCELXP mais avec certaines versions plus anciennes.</li>
<li><strong>FOREGROUND</strong> modifie la couleur du texte</li>
<li><strong>FONT_STYLE</strong> empêche l&#8217;inclinaison par défaut (enlever l&#8217;italique : <em>roman</em>, mettre en italic : <em>italic</em>)</li>
<li><strong>FONT_WEIGHT</strong> enlève la côté gras présent par défaut (enlever les gras : <em>medium</em>, mettre en gras : <em>bold</em>)</li>
<li><strong>FONT_SIZE</strong> défini la taille des caractères</li>
<li><strong>FONT_FACE</strong> liste les polices à utiliser. Si plusieurs polices sont listées entre guillemets, la première disponible sur l&#8217;ordinateur sera retenue.</li>
</ul>
<p><span style="color:#ff6600;"><strong>2. Appeler le style dans l&#8217;instruction ODS TAGSETS.EXCELXP</strong></span></p>
<p>L&#8217;option STYLE= a été ajouté dans la première instruction ODS TAGSETS.EXCELXP . Elle est suivie du nom du style créé préalablement. Cela donne STYLE=XLS_TITL.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">ods</span> tagsets.excelxp <span style="color:#0000ff;">file</span>=<span style="color:#800080;">&#8216;C:/sasref/class.xls&#8217;</span> <span style="color:#0000ff;">style</span>=xls_titl<br />
options(embedded_titles=<span style="color:#800080;">&#8216;yes&#8217;</span><br />
embedded_footnotes=<span style="color:#800080;">&#8216;yes&#8217;</span>);</span></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">title </span><span style="color:#800080;">&#8216;Titre&#8217;</span>;<br />
<span style="color:#0000ff;">footnote </span><span style="color:#800080;">&#8216;Pied&#8217;</span>;<br />
<span style="color:#0000ff;">ods</span> tagsets.excelxp;</span></p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc report</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class nowd;<br />
<span style="color:#0000ff;">columns</span> name age;<br />
<span style="color:#0000ff;">define</span> name/<span style="color:#0000ff;">display</span> <span style="color:#800080;">&#8216;Nom&#8217;</span>;<br />
<span style="color:#0000ff;">define</span> age /<span style="color:#0000ff;">display</span> <span style="color:#800080;">&#8216;Age&#8217;</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods</span> tagsets.excelxp <span style="color:#0000ff;">close</span>;<br />
<span style="color:#0000ff;">ods listing</span>;</span></p>
<p>Pour le reste des explications concernant cette syntaxe, reportez-vous à <a title="ods tagsets excelxp titre pied de page embedded_titles embedded_footnotes" href="http://www.sasreference.fr/2009/07/09/tagsets_xls_titre/">l&#8217;article de la semaine dernière</a>.</p>
<p><span style="color:#ff6600;"><strong>3. Voir le résultat</strong></span></p>
<p><img class="alignnone size-full wp-image-1927" title="02_xls_title" src="http://thesasreference.wordpress.com/files/2009/07/02_xls_title.jpg" alt="02_xls_title" width="425" height="537" /></p>
<p><span style="color:#ff6600;"><strong>Lectures complémentaires :</strong></span></p>
<ul>
<li><a title="couleur sas" href="http://www.sasreference.fr/2008/11/21/couleurs_sas/">Choisir ses couleurs sous SAS</a></li>
<li><a title="ods tagsets excelxp titre pied de page embedded_titles embedded_footnotes" href="http://www.sasreference.fr/2009/07/09/tagsets_xls_titre/">Ajouter les titres et pieds-de-page dans un fichier .xls</a></li>
<li><a title="instruction title sous sas" href="../2008/03/28/9-points-a-savoir-sur-les-titres/">9 points pour personnaliser ses titres</a></li>
<li><a href="../2009/06/01/ods_tagsets_excelxp/">En-tête et pied-de-page avec TAGSETX.EXCELXP</a> (print_header et print_footer)</li>
<li><a title="débuter avec ods tagsets excelxp" href="../2008/05/12/ods_tagsets_excelxp_1/">Mes premiers pas avec ODS TAGSETX.EXCELXP (1/3)</a></li>
<li><a title="débuter avec ods tagsets excelxp" href="../2008/05/19/ods_tagsets_excelxp_2/">Mes premiers pas avec ODS TAGSETX.EXCELXP (2/3)</a></li>
<li><a title="ods tagsets excelxp débuter" href="../2008/05/26/ods_tagsets_excelxp_3/">Mes premiers pas avec ODS TAGSETS.EXCELXP (3/3)</a></li>
<li><a title="mise à jour tagsets excelxp" href="../2009/06/04/tagsets_excelxp_update/">Mettre à jour ses TAGSETS pour EXCELXP</a></li>
</ul>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Ajouter les titres et pieds-de-page dans la feuille de calcul du fichier .xls]]></title>
<link>http://thesasreference.wordpress.com/2009/07/09/tagsets_xls_titre/</link>
<pubDate>Thu, 09 Jul 2009 19:55:14 +0000</pubDate>
<dc:creator>The SAS Reference</dc:creator>
<guid>http://thesasreference.wordpress.com/2009/07/09/tagsets_xls_titre/</guid>
<description><![CDATA[Lors de la création d&#8217;un fichier .xls au moyen de la syntaxe ODS TAGSETS.EXCELXP sous SAS, le ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Lors de la création d&#8217;un fichier .xls au moyen de la syntaxe ODS TAGSETS.EXCELXP sous SAS, le contenu des instructions TITLE et FOOTNOTE est envoyé respectivement dans l&#8217;entête et pied-de-page du fichier. Ils ne sont donc visibles qu&#8217;à l&#8217;impression.</p>
<p>Pour insérer le contenu des instructions TITLE et FOOTNOTE dans la feuille de calcul, il faudra ajouter deux options dans l&#8217;instruction ODS TAGSETX.EXCELXP : EMBEDDED_TITLES etEMBEDDED_FOOTNOTES.</p>
<p><strong><span style="color:#ff6600;">1. Le code</span></strong></p>
<p>Voici le code pour l&#8217;exemple. Vous noterez que j&#8217;ai rajouté une instruction ODS&#8230; juste après les instructions TITLE et FOOTNOTE. Cela permet à SAS de mettre à jour les titres et pieds-de-page qu&#8217;il a en mémoire. Cela sera pratique lorsque vous aurez plusieurs feuilles de calculs avec des titres différents. Autrement, vous pouvez ajouter les instructions TITLE et FOOTNOTES avant la première instruction ODS TAGSETS.EXCELXP.</p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">ods listing close</span>;<br />
<span style="color:#0000ff;">ods</span> tagsets.excelxp <span style="color:#0000ff;">file</span>=<span style="color:#800080;">&#8216;C:/sasref/class.xls&#8217;</span><br />
options(embedded_titles=<span style="color:#800080;">&#8216;yes&#8217;</span><br />
embedded_footnotes=<span style="color:#800080;">&#8216;yes&#8217;</span>);</span></p>
<p><span style="font-family:courier;"><span style="color:#0000ff;">title</span> <span style="color:#800080;">&#8216;Titre&#8217;</span>;<br />
<span style="color:#0000ff;">footnote</span> <span style="color:#800080;">&#8216;Pied&#8217;</span>;<br />
<span style="color:#0000ff;">ods </span>tagsets.excelxp;</span></p>
<p><span style="font-family:courier;"><span style="color:#000080;"><strong>proc report</strong></span> <span style="color:#0000ff;">data</span>=sashelp.class nowd;<br />
<span style="color:#0000ff;">columns</span> name age;<br />
<span style="color:#0000ff;">define</span> name/<span style="color:#0000ff;">display</span> <span style="color:#800080;">&#8216;Nom&#8217;</span>;<br />
<span style="color:#0000ff;">define </span>age /<span style="color:#0000ff;">display</span> <span style="color:#800080;">&#8216;Age&#8217;</span>;<br />
<span style="color:#000080;"><strong>run</strong></span>;</span></p>
<p><span style="font-family:courier;">ods tagsets.excelxp close;<br />
ods listing;</span></p>
<p>L&#8217;option NOWD est propre à un environnement Windows. Cela évite l&#8217;ouverture de la fenêtre REPORT</p>
<p><span style="color:#ff6600;"><strong>2. Voir le résultat</strong></span></p>
<p><img class="alignnone size-full wp-image-1923" title="Résultat ods tagsets.excelxp options embedded_titles embedded_footnotes" src="http://thesasreference.wordpress.com/files/2009/07/01_xls_title.jpg" alt="Résultat ods tagsets.excelxp options embedded_titles embedded_footnotes" width="416" height="557" /></p>
<p><span style="color:#ff6600;"><strong>3. Enlever les lignes blanches entre les titres/pieds-de-page et la table<br />
</strong></span></p>
<p>Pour empêcher l&#8217;insertion d&#8217;une ligne entre le(s) titre(s) et la table, le(s) pied(s)-de-page et la table, il faut faire appel à l&#8217;option SKIP_SPACE=.</p>
<p>Avant d&#8217;aller plus loin, il faut noter que</p>
<ul>
<li>la ligne d&#8217;espace entre le titre est la table est lié au TITRE et</li>
<li>la ligne entre la table et le pied-de-page est lié à la TABLE et non au pied-de-page.</li>
</ul>
<p>Cette option de l&#8217;instruction ODS TAGSETS.EXCELXP est composée de 5 nombres.</p>
<ul>
<li>Le premier nombre fait référence à la TABLE</li>
<li>Le 3ème nombre est lié au TITRE</li>
<li>Le 4ème nombre fait référence au PIED-DE-PAGE.</li>
</ul>
<p>Par défaut SKIP_SPACE=&#8217;1,0,1,1,1&#8242;.</p>
<p>Pour ôter les lignes séparant la table des titres et pieds-de-page, on aura : SKIP_SPACE=&#8217;0,0,0,1,1&#8242;. On enlevera la ligne après la table avec le premier zéro et la ligne après le titre avec le troisième zéro.</p>
<p><img class="alignnone size-full wp-image-1936" title="01_xls_title_extra" src="http://thesasreference.wordpress.com/files/2009/07/01_xls_title_extra.jpg" alt="01_xls_title_extra" width="425" height="119" /></p>
<p><span style="color:#ff6600;"><strong>A venir</strong></span></p>
<p>Je vous propose de découvrir dans les deux articles à venir des compléments sur les titres et pieds-de-page avec ODS TAGSETS.EXCELXP :</p>
<ul>
<li> Créer un style pour personnaliser les couleurs, polices des titres/pieds-de-page avec un PROC TEMPLATE.</li>
<li>Utiliser un titre plus grand que la largeur donnée par les colonnes du tableau</li>
</ul>
<p><span style="color:#ff6600;"><strong>Lectures complémentaires</strong></span></p>
<ul>
<li><a title="instruction title sous sas" href="http://thesasreference.wordpress.com/2008/03/28/9-points-a-savoir-sur-les-titres/">9 points pour personnaliser ses titres</a></li>
<li><a href="http://thesasreference.wordpress.com/2009/06/01/ods_tagsets_excelxp/">En-tête et pied-de-page avec TAGSETX.EXCELXP</a> (print_header et print_footer)</li>
<li><a title="débuter avec ods tagsets excelxp" href="http://thesasreference.wordpress.com/2008/05/12/ods_tagsets_excelxp_1/">Mes premiers pas avec ODS TAGSETX.EXCELXP (1/3)</a></li>
<li><a title="débuter avec ods tagsets excelxp" href="http://thesasreference.wordpress.com/2008/05/19/ods_tagsets_excelxp_2/">Mes premiers pas avec ODS TAGSETX.EXCELXP (2/3)</a></li>
<li><a title="ods tagsets excelxp débuter" href="http://thesasreference.wordpress.com/2008/05/26/ods_tagsets_excelxp_3/">Mes premiers pas avec ODS TAGSETS.EXCELXP (3/3)</a></li>
<li><a title="mise à jour tagsets excelxp" href="http://thesasreference.wordpress.com/2009/06/04/tagsets_excelxp_update/">Mettre à jour ses TAGSETS pour EXCELXP</a></li>
</ul>
</div>]]></content:encoded>
</item>

</channel>
</rss>
