<?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: Extract all characters from a variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95498#M20112</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thx, Shiva! What works! What does it do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers, Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Aug 2012 15:35:28 GMT</pubDate>
    <dc:creator>sfmeier</dc:creator>
    <dc:date>2012-08-16T15:35:28Z</dc:date>
    <item>
      <title>Extract all characters from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95496#M20110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a (macro) variable with a value in the form&lt;/P&gt;&lt;P&gt;"AB";"AG";"FZ","IE"&lt;/P&gt;&lt;P&gt;of variable length.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to create a new variable with all the characters from my (macro) variable and blanks in between, i.e.&lt;/P&gt;&lt;P&gt;AB AG FZ IE&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the SCAN function in a do loop in the DATA step but I got an error because of the ;s in the value of the (macro) variable.&lt;/P&gt;&lt;P&gt;How can I get it done?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thx,&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 09:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95496#M20110</guid>
      <dc:creator>sfmeier</dc:creator>
      <dc:date>2012-08-16T09:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Extract all characters from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95497#M20111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this..Hope it helps...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let x=%str("AB";"AG";"FZ","IE");&lt;/P&gt;&lt;P&gt;%let xx1 =%sysfunc(compbl(%sysfunc(translate(&amp;amp;x,' ','" ; ,'))));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 10:22:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95497#M20111</guid>
      <dc:creator>shivas</dc:creator>
      <dc:date>2012-08-16T10:22:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract all characters from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95498#M20112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thx, Shiva! What works! What does it do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers, Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 15:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95498#M20112</guid>
      <dc:creator>sfmeier</dc:creator>
      <dc:date>2012-08-16T15:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Extract all characters from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95499#M20113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In this solution the TRANSLATE function is changing the special characters to blanks, and then the COMPBL function converts multiple blanks to a single blank.&amp;nbsp; There are other functions that could have also been used COMPRESS and DEQUOTE among them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also this soution uses single quotes to delineate the text strings in the TRANSLATE function.&amp;nbsp; When using macro language elements this technique can have unintended consequences.&amp;nbsp; Macro language quoting functions such as %STR and %BQUOTE, shown below, do not have these issues. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let xx2 =%sysfunc(compbl(%sysfunc(translate(&amp;amp;x,%str( ),%bquote(" ; ,)))));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I once had got a number of consulting hours to debug a program, ultimately the problem was found in the following code fragment&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %scan(&amp;amp;name, &amp;amp;i, ' ')&lt;/P&gt;&lt;P&gt;which works fine unless the &amp;amp;name contains an apostrophe such as O'Conner&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 17:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95499#M20113</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2012-08-16T17:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Extract all characters from a variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95500#M20114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thx!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Aug 2012 06:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-all-characters-from-a-variable/m-p/95500#M20114</guid>
      <dc:creator>sfmeier</dc:creator>
      <dc:date>2012-08-20T06:59:07Z</dc:date>
    </item>
  </channel>
</rss>

