<?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: Removing a character from a macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470966#M120571</link>
    <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this.&lt;/P&gt;&lt;P&gt;If i use&amp;nbsp;&lt;SPAN&gt;%let a="P50001"; then it is also not working.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jun 2018 04:26:01 GMT</pubDate>
    <dc:creator>hpahuja84</dc:creator>
    <dc:date>2018-06-18T04:26:01Z</dc:date>
    <item>
      <title>Removing a character from a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470890#M120534</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to remove character from macro variable. For example in below code, i want to remove character P so i am using byte(80). but&lt;/P&gt;&lt;P&gt;its not working and instead of P it is removing 0 . I dont want to use "P" as second argument .Only byte or hexadecimal is allowed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let a="p50001";&lt;/P&gt;&lt;P&gt;data z;&lt;BR /&gt;c=%sysfunc(compress(&amp;amp;a,byte(80)));&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jun 2018 16:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470890#M120534</guid>
      <dc:creator>hpahuja84</dc:creator>
      <dc:date>2018-06-17T16:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a character from a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470893#M120536</link>
      <description>&lt;P&gt;You are in a data step, so %sysfunc is not needed, and most probably harmful.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jun 2018 16:42:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470893#M120536</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-17T16:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a character from a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470898#M120539</link>
      <description>&lt;P&gt;Byte 80 is a capital P, and your variable is lower case. Strings are case sensitive.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216066"&gt;@hpahuja84&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to remove character from macro variable. For example in below code, i want to remove character P so i am using byte(80). but&lt;/P&gt;
&lt;P&gt;its not working and instead of P it is removing 0 . I dont want to use "P" as second argument .Only byte or hexadecimal is allowed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let a="p50001";&lt;/P&gt;
&lt;P&gt;data z;&lt;BR /&gt;c=%sysfunc(compress(&amp;amp;a,byte(80)));&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jun 2018 18:12:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470898#M120539</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-17T18:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a character from a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470966#M120571</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for this.&lt;/P&gt;&lt;P&gt;If i use&amp;nbsp;&lt;SPAN&gt;%let a="P50001"; then it is also not working.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 04:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470966#M120571</guid>
      <dc:creator>hpahuja84</dc:creator>
      <dc:date>2018-06-18T04:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a character from a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470967#M120572</link>
      <description>&lt;P&gt;Thanks Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So is there any alternate solution for this.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 04:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470967#M120572</guid>
      <dc:creator>hpahuja84</dc:creator>
      <dc:date>2018-06-18T04:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a character from a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470974#M120575</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let a="P50001";
data z;
  c=compress(&amp;amp;a,byte(80));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or even better:&lt;/P&gt;
&lt;PRE&gt;%let a=P50001;
data z;
  c=compress("&amp;amp;a",byte(80));
run;


&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jun 2018 06:08:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470974#M120575</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-06-18T06:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a character from a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470978#M120576</link>
      <description>Why byte(80) and not 'P'?</description>
      <pubDate>Mon, 18 Jun 2018 06:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470978#M120576</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-06-18T06:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a character from a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470979#M120577</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216066"&gt;@hpahuja84&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Kurt,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So is there any alternate solution for this.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;First of all, as soon as you use the macro function %sysfunc, the whole argument inside that function turns into macro code and needs to be written as such:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let a="P50001";

data z;
c=%sysfunc(compress(&amp;amp;a,%sysfunc(byte(80))));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Without the inner sysfunc, the compress function will receive the &lt;EM&gt;string&lt;/EM&gt; "byte(80)" as its second argument, and remove all the zeros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I do not see why one would use the byte() function to denote a single character, when you only have to write that character as such:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let a=P50001;
data z;
  c=compress("&amp;amp;a","P");
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If, of course, you want to write unmaintainable obfuscated code, you should go some steps further:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let a="P50001";

data z;
c=%sysfunc(compress(&amp;amp;a,%sysfunc(byte(%eval(%sysfunc(intnx(month,'01jan1960'd,2,s))+20)))));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jun 2018 06:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470979#M120577</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-18T06:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a character from a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470980#M120578</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/43025"&gt;@error_prone&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Why byte(80) and not 'P'?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Exactly.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 06:58:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/470980#M120578</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-18T06:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a character from a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/471038#M120612</link>
      <description>&lt;P&gt;Thankyou very much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is working now. I used byte function because in some other examples, i have to use same logic to remove non printable characters for which byte function is only needed.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jun 2018 12:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-a-character-from-a-macro-variable/m-p/471038#M120612</guid>
      <dc:creator>hpahuja84</dc:creator>
      <dc:date>2018-06-18T12:05:48Z</dc:date>
    </item>
  </channel>
</rss>

