<?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 seperate data from a column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/seperate-data-from-a-column/m-p/720807#M223318</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;please help to achieve below .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input id  stores $50.;
datalines;
123 Target||Big W||Nordstorm||Macys
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;want;
------
id  count
123 4&lt;/PRE&gt;</description>
    <pubDate>Mon, 22 Feb 2021 03:17:21 GMT</pubDate>
    <dc:creator>dennis_oz</dc:creator>
    <dc:date>2021-02-22T03:17:21Z</dc:date>
    <item>
      <title>seperate data from a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seperate-data-from-a-column/m-p/720807#M223318</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;please help to achieve below .&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input id  stores $50.;
datalines;
123 Target||Big W||Nordstorm||Macys
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;want;
------
id  count
123 4&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2021 03:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seperate-data-from-a-column/m-p/720807#M223318</guid>
      <dc:creator>dennis_oz</dc:creator>
      <dc:date>2021-02-22T03:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: seperate data from a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seperate-data-from-a-column/m-p/720808#M223319</link>
      <description>&lt;P&gt;Are you asking how to count?&amp;nbsp; Did you check out the COUNTW() function?&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=fedsqlref&amp;amp;docsetTarget=p168a7v3fahigkn1pbaymi7g0jla.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=fedsqlref&amp;amp;docsetTarget=p168a7v3fahigkn1pbaymi7g0jla.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 03:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seperate-data-from-a-column/m-p/720808#M223319</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-22T03:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: seperate data from a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seperate-data-from-a-column/m-p/720809#M223320</link>
      <description>&lt;P&gt;If the below helps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
	input id  stores $50.;
	datalines;
123 Target||Big W||Nordstorm||Macys
run;

data want (drop=stores);
	set a;
	store_cnt = countw(stores,"||");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2021 03:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seperate-data-from-a-column/m-p/720809#M223320</guid>
      <dc:creator>qoit</dc:creator>
      <dc:date>2021-02-22T03:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: seperate data from a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/seperate-data-from-a-column/m-p/720842#M223333</link>
      <description>&lt;P&gt;Please check the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input id  stores $50.;
	datalines;
123 Target||Big W||Nordstorm||Macys
456 Source||x|y||Westwind||Harrods
run;

data want;
   set have;
   count = countw(stores, "||");&lt;BR /&gt;   drop stores;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The result for id=456 seems to be wrong. Unfortunately, countw has no option allowing delimiters longer than one char. The following code replaces || with ~ and calls countw afterwards.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;

   count_word = countw(stores, "||");
   count_better = countw(tranwrd(stores, '||', '~'), '~');

   drop stores;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Feb 2021 07:17:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/seperate-data-from-a-column/m-p/720842#M223333</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-02-22T07:17:45Z</dc:date>
    </item>
  </channel>
</rss>

