<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to Label Plot Axis with Macro Variable Name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587167#M167676</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a macro where the input variables are the names of the variables from a dataset to be plotted using sgplot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to automate the axis labeling, so that the input variable name can be formatted to a string to be used in &lt;FONT face="courier new,courier"&gt;xaxis label.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I have made a proc format to convert variable names into axis labels, but not sure what to do with it.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;If my explanation doesn't seem clear, here's psuedocode to illustrate what I'm looking for.&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;%macro my_macro(data, variable_name);

    %include 'path to variable name formats'

    /* Some way of using format to turn variable_name into string */

    proc sgplot 
    /* Plot stuff */
    xaxis label = /* String */ ;
    run;

%mend my_macro

   

&lt;/PRE&gt;&lt;P&gt;Hope this is clear enough, thanks in advance for your help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 09 Sep 2019 09:06:38 GMT</pubDate>
    <dc:creator>RoddyJ</dc:creator>
    <dc:date>2019-09-09T09:06:38Z</dc:date>
    <item>
      <title>How to Label Plot Axis with Macro Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587167#M167676</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a macro where the input variables are the names of the variables from a dataset to be plotted using sgplot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to automate the axis labeling, so that the input variable name can be formatted to a string to be used in &lt;FONT face="courier new,courier"&gt;xaxis label.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;I have made a proc format to convert variable names into axis labels, but not sure what to do with it.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;If my explanation doesn't seem clear, here's psuedocode to illustrate what I'm looking for.&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;%macro my_macro(data, variable_name);

    %include 'path to variable name formats'

    /* Some way of using format to turn variable_name into string */

    proc sgplot 
    /* Plot stuff */
    xaxis label = /* String */ ;
    run;

%mend my_macro

   

&lt;/PRE&gt;&lt;P&gt;Hope this is clear enough, thanks in advance for your help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 09:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587167#M167676</guid>
      <dc:creator>RoddyJ</dc:creator>
      <dc:date>2019-09-09T09:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to Label Plot Axis with Macro Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587173#M167680</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/289103"&gt;@RoddyJ&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this simplified example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $vlblfmt
'age'='Age in years'
'sex'='Gender';
run;

%macro test(var=);
proc sgplot data=sashelp.class;
vbar &amp;amp;var;
xaxis label="%sysfunc(putc(%lowcase(&amp;amp;var),$vlblfmt.))";
run;
%mend test;

%test(var=Age)
%test(var=Sex)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Sep 2019 09:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587173#M167680</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-09-09T09:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to Label Plot Axis with Macro Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587175#M167682</link>
      <description>&lt;P&gt;That's exactly what I wanted, thank you so much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a few questions about this snippet of code and would be really grateful if you could answer them too:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token string"&gt;"%sysfunc(putc(%lowcase(&amp;amp;var),$vlblfmt.))"&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp;Why is it enclosed in quotes, I thought putc would return the format as a string?&lt;/LI&gt;&lt;LI&gt;What is %lowcase doing?&lt;/LI&gt;&lt;LI&gt;What is %sysfunc doing?&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Thanks again for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 09:45:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587175#M167682</guid>
      <dc:creator>RoddyJ</dc:creator>
      <dc:date>2019-09-09T09:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to Label Plot Axis with Macro Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587179#M167683</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;CODE class="  language-sas"&gt;&lt;/CODE&gt;
&lt;UL&gt;
&lt;LI&gt;Why is it enclosed in quotes, I thought putc would return the format as a string?&lt;/LI&gt;
&lt;/UL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The LABEL= option requires quotes according to the &lt;A href="https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetVersion=9.4&amp;amp;docsetTarget=p07m2vpyq75fgan14m6g5pphnwlr.htm&amp;amp;locale=en#n1ujjft95cl9xzn0zh4jb5yc29xc" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;. A string is not quoted by default.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;UL&gt;
&lt;LI&gt;What is %lowcase doing?&lt;/LI&gt;
&lt;/UL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=p0z7ubhlepe3h7n1ivnyuawn6yze.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;%LOWCASE autocall macro&lt;/A&gt; changes uppercase letters such as the "A" in "Age" to lowercase so that the assignment of the labels is case-insensitive. (Without that change "Age" or "AGE" would not be found in the format definition, which in my example uses only lowercase values like "age.")&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;UL&gt;
&lt;LI&gt;What is %sysfunc doing?&lt;/LI&gt;
&lt;/UL&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=p1o13d7wb2zfcnn19s5ssl2zdxvi.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;%SYSFUNC&lt;/A&gt; executes the SAS function in its argument, here: the PUTC function.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Sep 2019 10:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587179#M167683</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-09-09T10:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to Label Plot Axis with Macro Variable Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587188#M167688</link>
      <description>Thanks so much for your help on this, really appreciate it.</description>
      <pubDate>Mon, 09 Sep 2019 10:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Label-Plot-Axis-with-Macro-Variable-Name/m-p/587188#M167688</guid>
      <dc:creator>RoddyJ</dc:creator>
      <dc:date>2019-09-09T10:31:14Z</dc:date>
    </item>
  </channel>
</rss>

