<?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 use compress keep digit on macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-compress-keep-digit-on-macro-variable/m-p/375725#M90114</link>
    <description>&lt;P&gt;Using COMPRESS with kd is dangerous.&amp;nbsp; It gives the wrong answer if digits appear elsewhere in the incoming file name.&amp;nbsp; You would be better off using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;%let final_digits = %scan(%scan(&amp;amp;dsn, 1, %str( )), -1, _)&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jul 2017 15:01:50 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-07-13T15:01:50Z</dc:date>
    <item>
      <title>how to use compress keep digit on macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-compress-keep-digit-on-macro-variable/m-p/375709#M90107</link>
      <description>&lt;P&gt;%put &amp;amp;dsn;&lt;BR /&gt;File_x_20170116 File_Y_20170220 File_z_20170320&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put %scan(&amp;amp;dsn,1,' ');&lt;BR /&gt;File_x_20170116&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want ouput from below function as '20170116' [digits from Fiile_x_20170116]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%put %sysfunc(compress(%scan(&amp;amp;dsn,1,' '), ,'kd'))&lt;BR /&gt;WARNING: In a call to the COMPRESS function or routine, the modifier "'" not valid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is there any way to get it ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Atul Deshmukh&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 14:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-compress-keep-digit-on-macro-variable/m-p/375709#M90107</guid>
      <dc:creator>atul_desh</dc:creator>
      <dc:date>2017-07-13T14:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to use compress keep digit on macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-compress-keep-digit-on-macro-variable/m-p/375714#M90110</link>
      <description>&lt;PRE&gt;%let dsn=File_x_20170116 File_Y_20170220 File_z_20170320;
 
%put %scan(&amp;amp;dsn,1,' ');
 
%put %sysfunc(compress(%scan(&amp;amp;dsn,1,' '),,kd));
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 14:51:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-compress-keep-digit-on-macro-variable/m-p/375714#M90110</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-13T14:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to use compress keep digit on macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-compress-keep-digit-on-macro-variable/m-p/375725#M90114</link>
      <description>&lt;P&gt;Using COMPRESS with kd is dangerous.&amp;nbsp; It gives the wrong answer if digits appear elsewhere in the incoming file name.&amp;nbsp; You would be better off using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;%let final_digits = %scan(%scan(&amp;amp;dsn, 1, %str( )), -1, _)&lt;/FONT&gt;&lt;FONT face="Lucida Console" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 15:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-compress-keep-digit-on-macro-variable/m-p/375725#M90114</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-07-13T15:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to use compress keep digit on macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-use-compress-keep-digit-on-macro-variable/m-p/375740#M90120</link>
      <description>&lt;P&gt;&lt;STRONG&gt;You do not need to put quotes around string literals in macro code.&lt;/STRONG&gt; Everything is a string to the macro processor.&lt;/P&gt;
&lt;P&gt;So this code that you would use in a data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want = compress(scan(DSN,1,' '),,'kd');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Would look more like this in macro code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let want=%sysfunc(compress(%scan(&amp;amp;dsn,1,%str( )),,kd)) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What you ran was more like this in data step code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;want=compress(scan(DSN,1,"' '"),,"'kd'") ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jul 2017 15:45:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-use-compress-keep-digit-on-macro-variable/m-p/375740#M90120</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-13T15:45:27Z</dc:date>
    </item>
  </channel>
</rss>

