<?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 Re: How to assign global macro variable with SYNPUTX() in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-global-macro-variable-with-SYNPUTX/m-p/788787#M252296</link>
    <description>&lt;P&gt;First place to check should always be the&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1fa0ay5pzr9yun1mvqxv8ipzd4d.htm" target="_self"&gt; documentation&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN class="xisDoc-keyword"&gt;CALL SYMPUTX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;macro-variable&lt;/EM&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;value&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class="xisDoc-optional"&gt;&amp;lt;,&amp;nbsp;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 class="xisDoc-argument"&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;&lt;/H4&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies a character constant, variable, or expression. The value of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is not case sensitive. The first non-blank character in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;specifies the symbol table in which to store the macro variable. The following values are valid as the first non-blank character in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;:&lt;/P&gt;
&lt;DIV id="p16rxe2wnz9us9n17mdhd8mgih89" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;G&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;specifies that the macro variable is stored in the global symbol table, even if the local symbol table exists.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="p0u7a2o4yp95cnn1p57rqy17j2ir" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;L&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies that the macro variable is stored in the most local symbol table that exists, which will be the global symbol table, if used outside a macro.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV id="n1ra7vcb4u7wipn19n0nmpqahoze" class="xisDoc-argDescriptionPair"&gt;
&lt;BLOCKQUOTE&gt;
&lt;H4 class="xisDoc-argument"&gt;F&lt;/H4&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies that if the macro variable exists in any symbol table, CALL SYMPUTX uses the version in the most local symbol table in which it exists. If the macro variable does not exist, CALL SYMPUTX stores the variable in the most local symbol table.&lt;/P&gt;
&lt;DIV id="p0a8csw8mjawgbn1saw1z0fi7ibm" class="xisDoc-note"&gt;&lt;STRONG&gt;&lt;SPAN class="xisDoc-noteGenText"&gt;Note:&amp;nbsp;&lt;/SPAN&gt;If you omit&amp;nbsp;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;, leave it blank or use any other symbol other than G, L, or F. CALL SYMPUTX stores the macro variable in the same symbol table as does the CALL SYMPUT routine.&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-note"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="xisDoc-note"&gt;So add, g to your call symput function.&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="xisDoc-note"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="xisDoc-note"&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx(vname(p_), p_, 'G' );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV class="xisDoc-note"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="xisDoc-note"&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409584"&gt;@hellohere&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have the macro below to assign percentiles to macro variable.&lt;/P&gt;
&lt;P&gt;It works,&amp;nbsp;%pctvar(sashelp.cars, Horsepower, hp);&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BUT the macro variables are LOCAL only within the macro. How to make them global?! Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro pctvar(ds, var, note);&lt;BR /&gt;proc univariate data=&amp;amp;ds. noprint;&lt;BR /&gt;var &amp;amp;var.;&lt;BR /&gt;output pctlpre=p_ pctlpts= 5 to 95 by 5;&lt;BR /&gt;run;&lt;BR /&gt;proc print; run;&lt;BR /&gt;data _null_;&lt;BR /&gt;set;&lt;BR /&gt;array p_ p_:;&lt;BR /&gt;do over p_;&lt;BR /&gt;call symputx(vname(p_),p_); /*only local, not global*/&lt;BR /&gt;end;&lt;BR /&gt;stop;&lt;BR /&gt;run;quit;&lt;BR /&gt;%put "p_5=&amp;amp;p_5. p_50=&amp;amp;p_50. p_95=&amp;amp;p_95.";&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
    <pubDate>Fri, 07 Jan 2022 03:54:24 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-01-07T03:54:24Z</dc:date>
    <item>
      <title>How to assign global macro variable with SYNPUTX()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-global-macro-variable-with-SYNPUTX/m-p/788785#M252294</link>
      <description>&lt;P&gt;I have the macro below to assign percentiles to macro variable.&lt;/P&gt;&lt;P&gt;It works,&amp;nbsp;%pctvar(sashelp.cars, Horsepower, hp);&amp;nbsp;&lt;/P&gt;&lt;P&gt;BUT the macro variables are LOCAL only within the macro. How to make them global?! Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro pctvar(ds, var, note);&lt;BR /&gt;proc univariate data=&amp;amp;ds. noprint;&lt;BR /&gt;var &amp;amp;var.;&lt;BR /&gt;output pctlpre=p_ pctlpts= 5 to 95 by 5;&lt;BR /&gt;run;&lt;BR /&gt;proc print; run;&lt;BR /&gt;data _null_;&lt;BR /&gt;set;&lt;BR /&gt;array p_ p_:;&lt;BR /&gt;do over p_;&lt;BR /&gt;call symputx(vname(p_),p_); /*only local, not global*/&lt;BR /&gt;end;&lt;BR /&gt;stop;&lt;BR /&gt;run;quit;&lt;BR /&gt;%put "p_5=&amp;amp;p_5. p_50=&amp;amp;p_50. p_95=&amp;amp;p_95.";&lt;BR /&gt;%mend;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 03:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-global-macro-variable-with-SYNPUTX/m-p/788785#M252294</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2022-01-07T03:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign global macro variable with SYNPUTX()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-global-macro-variable-with-SYNPUTX/m-p/788787#M252296</link>
      <description>&lt;P&gt;First place to check should always be the&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/p1fa0ay5pzr9yun1mvqxv8ipzd4d.htm" target="_self"&gt; documentation&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN class="xisDoc-keyword"&gt;CALL SYMPUTX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;macro-variable&lt;/EM&gt;&lt;SPAN&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;value&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class="xisDoc-optional"&gt;&amp;lt;,&amp;nbsp;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;&amp;gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 class="xisDoc-argument"&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;&lt;/H4&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies a character constant, variable, or expression. The value of&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is not case sensitive. The first non-blank character in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;specifies the symbol table in which to store the macro variable. The following values are valid as the first non-blank character in&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;:&lt;/P&gt;
&lt;DIV id="p16rxe2wnz9us9n17mdhd8mgih89" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;G&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;specifies that the macro variable is stored in the global symbol table, even if the local symbol table exists.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV id="p0u7a2o4yp95cnn1p57rqy17j2ir" class="xisDoc-argDescriptionPair"&gt;
&lt;H4 class="xisDoc-argument"&gt;L&lt;/H4&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies that the macro variable is stored in the most local symbol table that exists, which will be the global symbol table, if used outside a macro.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV id="n1ra7vcb4u7wipn19n0nmpqahoze" class="xisDoc-argDescriptionPair"&gt;
&lt;BLOCKQUOTE&gt;
&lt;H4 class="xisDoc-argument"&gt;F&lt;/H4&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;BLOCKQUOTE&gt;
&lt;P class="xisDoc-paraSimpleFirst"&gt;specifies that if the macro variable exists in any symbol table, CALL SYMPUTX uses the version in the most local symbol table in which it exists. If the macro variable does not exist, CALL SYMPUTX stores the variable in the most local symbol table.&lt;/P&gt;
&lt;DIV id="p0a8csw8mjawgbn1saw1z0fi7ibm" class="xisDoc-note"&gt;&lt;STRONG&gt;&lt;SPAN class="xisDoc-noteGenText"&gt;Note:&amp;nbsp;&lt;/SPAN&gt;If you omit&amp;nbsp;&lt;EM class="xisDoc-userSuppliedValue"&gt;symbol-table&lt;/EM&gt;, leave it blank or use any other symbol other than G, L, or F. CALL SYMPUTX stores the macro variable in the same symbol table as does the CALL SYMPUT routine.&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-note"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="xisDoc-note"&gt;So add, g to your call symput function.&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="xisDoc-note"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="xisDoc-note"&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call symputx(vname(p_), p_, 'G' );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV class="xisDoc-note"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="xisDoc-note"&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/409584"&gt;@hellohere&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have the macro below to assign percentiles to macro variable.&lt;/P&gt;
&lt;P&gt;It works,&amp;nbsp;%pctvar(sashelp.cars, Horsepower, hp);&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BUT the macro variables are LOCAL only within the macro. How to make them global?! Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro pctvar(ds, var, note);&lt;BR /&gt;proc univariate data=&amp;amp;ds. noprint;&lt;BR /&gt;var &amp;amp;var.;&lt;BR /&gt;output pctlpre=p_ pctlpts= 5 to 95 by 5;&lt;BR /&gt;run;&lt;BR /&gt;proc print; run;&lt;BR /&gt;data _null_;&lt;BR /&gt;set;&lt;BR /&gt;array p_ p_:;&lt;BR /&gt;do over p_;&lt;BR /&gt;call symputx(vname(p_),p_); /*only local, not global*/&lt;BR /&gt;end;&lt;BR /&gt;stop;&lt;BR /&gt;run;quit;&lt;BR /&gt;%put "p_5=&amp;amp;p_5. p_50=&amp;amp;p_50. p_95=&amp;amp;p_95.";&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 07 Jan 2022 03:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-global-macro-variable-with-SYNPUTX/m-p/788787#M252296</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-07T03:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign global macro variable with SYNPUTX()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-global-macro-variable-with-SYNPUTX/m-p/788788#M252297</link>
      <description>&lt;P&gt;And if you're looking to bin variables by percentiles, PROC RANK is a better option IMO.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jan 2022 03:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-global-macro-variable-with-SYNPUTX/m-p/788788#M252297</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-07T03:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign global macro variable with SYNPUTX()</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-global-macro-variable-with-SYNPUTX/m-p/863601#M341121</link>
      <description>&lt;P&gt;Reeza:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to do Proc Univariate with one BY Var here?!&lt;/P&gt;
&lt;P&gt;Say byvar has value 1,2,3,4, and to systematically save varx(one numeric) percentile cut into macro variables&lt;/P&gt;
&lt;P&gt;p_by_1_varx_10/20/30/....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 11 Mar 2023 13:07:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-global-macro-variable-with-SYNPUTX/m-p/863601#M341121</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2023-03-11T13:07:25Z</dc:date>
    </item>
  </channel>
</rss>

