<?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: Mask a variable in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820670#M20416</link>
    <description>&lt;P&gt;To use &amp;amp;MYVAR, you need to quote the variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myvar=crazy&amp;amp;609;
%put The value of MYVAR is %bquote(&amp;amp;myvar);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;%STR and %NRSTR should be used when you can see the special character in the text inside %STR() or %NRSTR(). In this case, when you use &amp;amp;myvar, you can't see the special character, you see a macro variable &amp;amp;myvar which may or may not contain special characters, so the quoting functions are needed here.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jun 2022 12:05:31 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-06-28T12:05:31Z</dc:date>
    <item>
      <title>Mask a variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820668#M20415</link>
      <description>&lt;P&gt;Hi there&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to use %nrstr and %str. I am passing my variable in the function however it wont work when trying to reference the value of the variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e.g.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let myvar = crazy&amp;amp;609

%let maskedname = %nrstr(&amp;amp;myvar.);
%put &amp;amp;maskedfile.;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the masking works fine when doing this but not when using the variable:&lt;/P&gt;
&lt;PRE&gt;%let maskedname = %nrstr(crazy&amp;amp;609);&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820668#M20415</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-06-28T12:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Mask a variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820670#M20416</link>
      <description>&lt;P&gt;To use &amp;amp;MYVAR, you need to quote the variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myvar=crazy&amp;amp;609;
%put The value of MYVAR is %bquote(&amp;amp;myvar);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;%STR and %NRSTR should be used when you can see the special character in the text inside %STR() or %NRSTR(). In this case, when you use &amp;amp;myvar, you can't see the special character, you see a macro variable &amp;amp;myvar which may or may not contain special characters, so the quoting functions are needed here.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820670#M20416</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-28T12:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Mask a variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820673#M20417</link>
      <description>&lt;P&gt;Hi Paige, thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would need to use NRSTR as&amp;nbsp; i have special characters in the name of the variable. What other alternatives are there?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820673#M20417</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-06-28T12:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Mask a variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820676#M20418</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338030"&gt;@Citrine10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Paige, thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would need to use NRSTR as&amp;nbsp; i have special characters in the name of the variable. What other alternatives are there?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Provide an example.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820676#M20418</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-28T12:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: Mask a variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820677#M20419</link>
      <description>&lt;LI-CODE lang="sas"&gt;%let myvar=crazy&amp;amp;609;
%put The value of MYVAR is %nrstr(&amp;amp;myvar);&lt;/LI-CODE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let myvar=craz!609;
%put The value of MYVAR is %nrstr(&amp;amp;myvar);&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820677#M20419</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-06-28T12:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Mask a variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820680#M20420</link>
      <description>&lt;P&gt;For this example, no quoting or %STR/%NRSTR is needed, but it will work with quoting&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myvar=craz!609;
%put The value of MYVAR is %bquote(&amp;amp;myvar);
%put The value of MYVAR is &amp;amp;myvar;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2022 12:49:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820680#M20420</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-28T12:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: Mask a variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820684#M20421</link>
      <description>ok but how will it work with some special characters and mnemonics as  %NRSTR masks &amp;amp; and %.</description>
      <pubDate>Tue, 28 Jun 2022 12:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820684#M20421</guid>
      <dc:creator>Citrine10</dc:creator>
      <dc:date>2022-06-28T12:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Mask a variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820689#M20422</link>
      <description>&lt;P&gt;You still need to give an example with mnemonics you are trying to mask.&amp;nbsp; If you're trying to mask &amp;amp; or % which result from resolving a macro variable and might be seen as a macro trigger, then you can use %superq, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myvar=craz&amp;amp;foo;   *will throw warning foo not resolved ;
%put The value of MYVAR is %superq(myvar); *no warning because &amp;amp; is masked ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that masking of &amp;amp; or % is only needed when they would be seen as macro trigger.&amp;nbsp; The macro processor knows that a macro name and macro variable name must start with a letter, so &amp;amp;609 or %609 cannot be seen as macro triggers.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myvar=craz&amp;amp;609; 
%put The value of MYVAR is &amp;amp;myvar;

%let myvar=craz%609; 
%put The value of MYVAR is &amp;amp;myvar;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Depending on how you use the macro variable, it's possible that in &amp;amp;609 the &amp;amp; might be seen as an AND operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro quoting is a hard subject.&amp;nbsp; It's an almost impossible subject to try to learn without an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 13:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820689#M20422</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-06-28T13:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Mask a variable</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820690#M20423</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/338030"&gt;@Citrine10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;ok but how will it work with some special characters and mnemonics as %NRSTR masks &amp;amp; and %.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Provide examples.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2022 13:32:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Mask-a-variable/m-p/820690#M20423</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-28T13:32:45Z</dc:date>
    </item>
  </channel>
</rss>

