<?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: Working with character variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Working-with-character-variables/m-p/117961#M24352</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HaiKuo,&lt;/P&gt;&lt;P&gt;countw() is a good way.&lt;/P&gt;&lt;P&gt;do i=1 to countw(var,';'); &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Nov 2012 04:01:55 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2012-11-06T04:01:55Z</dc:date>
    <item>
      <title>Working with character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-character-variables/m-p/117958#M24349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have a string variable which contains letters and ';' signs. for example:&amp;nbsp; &lt;STRONG&gt;A;B;A;A;B;C&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The length of these strings is not constant and varies by observations, so the next observation may be something like &lt;STRONG&gt;A;B &lt;/STRONG&gt;or even a single&lt;STRONG&gt; B&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I need to create variables to store each letter separately. for example for the first string, I need 6 separate variables, say alpha1, alpha2, alpha3, alpha4, alpha5 and alpha6 which each of them only contains one of the 6 letters appeared in the string. so alpha1 will be A, alpha2 will be B, alpha3 will be A and so on&lt;/P&gt;&lt;P&gt;For the second string, I will only need alpha1 to store A and alpha2 to storeB and finally for the third string, I just need alpha1 to store B and all other alpha variables to be empty. &lt;/P&gt;&lt;P&gt;My data base contains about 1 million observations so having a lot of if,then statements may not be the smartest solution. &lt;/P&gt;&lt;P&gt;Any suggestion is greatly appreciated! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2012 01:57:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-character-variables/m-p/117958#M24349</guid>
      <dc:creator>niam</dc:creator>
      <dc:date>2012-11-06T01:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Working with character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-character-variables/m-p/117959#M24350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input var $char20.;&lt;/P&gt;&lt;P&gt;CARDS4;&lt;/P&gt;&lt;P&gt;A;B;C;D;A;B&lt;/P&gt;&lt;P&gt;A;B;C&lt;/P&gt;&lt;P&gt;B;A;D;D&lt;/P&gt;&lt;P&gt;B&lt;/P&gt;&lt;P&gt;J;K;C;K;J;K;A;B;C;D&lt;/P&gt;&lt;P&gt;;;;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt; select (max(length(var))+1)/2 into :vn from have;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array alpha(&amp;amp;vn) $1.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(alpha) until (missing (alpha(i)));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; alpha(i)=scan(var,i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop i;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2012 02:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-character-variables/m-p/117959#M24350</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-06T02:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Working with character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-character-variables/m-p/117960#M24351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow! It worked beautifully! Thank you very much&lt;/P&gt;&lt;P&gt;I am jealous of your skills !&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2012 03:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-character-variables/m-p/117960#M24351</guid>
      <dc:creator>niam</dc:creator>
      <dc:date>2012-11-06T03:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Working with character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-character-variables/m-p/117961#M24352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HaiKuo,&lt;/P&gt;&lt;P&gt;countw() is a good way.&lt;/P&gt;&lt;P&gt;do i=1 to countw(var,';'); &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2012 04:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-character-variables/m-p/117961#M24352</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-11-06T04:01:55Z</dc:date>
    </item>
  </channel>
</rss>

