<?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: Output Parts of a String in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217802#M4727</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This worked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;degStudLevComma = "D1,D2";&lt;/P&gt;&lt;P&gt;total = countw(degStudLevComma, ',');&lt;/P&gt;&lt;P&gt;put total;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro testMacro();&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let degStudLevComma = "D1,D2";&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let total = %sysfunc(countw(&amp;amp;degStudLevComma, ','));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put total &amp;amp;total;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%testMacro();&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 May 2015 18:28:45 GMT</pubDate>
    <dc:creator>DavidPhillips2</dc:creator>
    <dc:date>2015-05-26T18:28:45Z</dc:date>
    <item>
      <title>Output Parts of a String</title>
      <link>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217795#M4720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In SAS 9.2&lt;/P&gt;&lt;P&gt;Is there a simple way to split a string?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL style="list-style-type: upper-alpha;"&gt;&lt;LI&gt;E.g. &lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;%Let baseString = D1 D2 D3;&lt;/P&gt;&lt;P&gt;For I = 0 to end;&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;Output D1 the first time;&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;Output D2 the second time;&lt;/P&gt;&lt;P style="text-indent: .5in;"&gt;Output D3 the third time;&lt;/P&gt;&lt;P&gt;End loop;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do not want to do this in a data step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 20:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217795#M4720</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2015-05-20T20:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Output Parts of a String</title>
      <link>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217796#M4721</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;How about using macro?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="22682" __jive_macro_name="message" class="jive_macro jive_macro_message" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 20:59:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217796#M4721</guid>
      <dc:creator>BrunoSilva</dc:creator>
      <dc:date>2015-05-20T20:59:32Z</dc:date>
    </item>
    <item>
      <title>Re: Output Parts of a String</title>
      <link>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217797#M4722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SCAN() or %SCAN()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; basestring='D1 D2 D3';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; do i=1 to countw(basestring);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; word = scan(basestring,i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; put i= word=;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%do i=1 %to %sysfunc(countw(&amp;amp;basestring));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %let word = %scan(&amp;amp;basestring,&amp;amp;i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; %put i=&amp;amp;i word=&amp;amp;word;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 21:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217797#M4722</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-05-20T21:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Output Parts of a String</title>
      <link>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217798#M4723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is a macro that I use that also puts everything you might need into macro variables. (I have just improved it a bit by stealing Tom's idea of using countw).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #000080; font-size: 12pt; font-family: Courier New;"&gt;%MACRO&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; makelist(base,list);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-size: 12pt; font-family: Courier New;"&gt;* create a set of macro variables named base1, base2 ... with values from list + list returned as &amp;lt;base&amp;gt;list;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%PUT&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &amp;amp;base &amp;amp;list;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%GLOBAL&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; n&amp;amp;base &amp;amp;base.list;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%LET&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &amp;amp;base.list =&amp;amp;list;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%LET&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; n&amp;amp;base=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%sysfunc&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;(countw(&amp;amp;list)); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%DO&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 12pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%TO&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &amp;amp;&amp;amp;n&amp;amp;base;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%GLOBAL&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &amp;amp;&amp;amp;base&amp;amp;&amp;amp;n&amp;amp;base;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%LET&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &amp;amp;&amp;amp;base&amp;amp;&amp;amp;n&amp;amp;base=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%SCAN&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;(&amp;amp;list,&amp;amp;&amp;amp;n&amp;amp;base);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%END&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; ; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%PUT&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; n&amp;amp;base = &amp;amp;&amp;amp;n&amp;amp;base;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%DO&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style=": ; color: #008080; font-size: 12pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%TO&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &amp;amp;&amp;amp;n&amp;amp;base;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%PUT&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &amp;amp;base&amp;amp;i &amp;amp;&amp;amp;&amp;amp;base&amp;amp;i; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 12pt; font-family: Courier New;"&gt;%END&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style=": ; color: #000080; font-size: 12pt; font-family: Courier New;"&gt;%MEND&lt;/STRONG&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; %&lt;STRONG&gt;&lt;EM&gt;makelist&lt;/EM&gt;&lt;/STRONG&gt;(test,D1 D2 D3);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can reference them with a loop in a macro eg. ...&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;PROC MEANS;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; VAR &amp;amp;testlist; * D1 D2 D3;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; OUTPUT OUT=testmeans MEAN=&lt;/SPAN&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;%DO I=1 %TO &amp;amp;ntest; &amp;amp;&amp;amp;test&amp;amp;i..m %END; ; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;The output dataset contains means in the variables D1m D2m and D3m.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12pt; font-family: Courier New;"&gt;&lt;BR /&gt;&lt;/SPAN&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 May 2015 21:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217798#M4723</guid>
      <dc:creator>KenDodds</dc:creator>
      <dc:date>2015-05-20T21:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Output Parts of a String</title>
      <link>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217799#M4724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A reference that might help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://blogs.sas.com/content/publishing/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/"&gt;http://blogs.sas.com/content/publishing/2015/01/30/sas-authors-tip-getting-the-macro-language-to-perform-a-do-loop-over-a-list-of-values/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 May 2015 12:34:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217799#M4724</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-05-21T12:34:36Z</dc:date>
    </item>
    <item>
      <title>Re: Output Parts of a String</title>
      <link>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217800#M4725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;degStudLevComma = "aa,b,a";&lt;/P&gt;&lt;P&gt;total = countc(&amp;amp;degStudLevComma, ',');&lt;/P&gt;&lt;P&gt;put "&amp;amp;total";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Arial',sans-serif; color: black; background: white;"&gt;In order to know when to end going through my string I need to use countc.&amp;nbsp; My string is delimited by commas.&amp;nbsp; When I do this I receive an error that I have too many arguments.&amp;nbsp; I’m guessing this is because my variable has commas in it that are acting like variable separators.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 17:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217800#M4725</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2015-05-26T17:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: Output Parts of a String</title>
      <link>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217801#M4726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You want the countW() function to see how many items are in your list.&amp;nbsp; You can included commas if they are properly quoted.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 18:03:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217801#M4726</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-05-26T18:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Output Parts of a String</title>
      <link>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217802#M4727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This worked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;degStudLevComma = "D1,D2";&lt;/P&gt;&lt;P&gt;total = countw(degStudLevComma, ',');&lt;/P&gt;&lt;P&gt;put total;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro testMacro();&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let degStudLevComma = "D1,D2";&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let total = %sysfunc(countw(&amp;amp;degStudLevComma, ','));&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put total &amp;amp;total;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%testMacro();&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 18:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217802#M4727</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2015-05-26T18:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Output Parts of a String</title>
      <link>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217803#M4728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Example with embedded commas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let x=This,list,has,"5, not 6 or 7,",words;&lt;/P&gt;&lt;P&gt;%let n=%sysfunc(countw(%superq(x),%str(,),qm));&lt;/P&gt;&lt;P&gt;%put &amp;amp;=n;&lt;/P&gt;&lt;P&gt;N=5&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 18:41:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Output-Parts-of-a-String/m-p/217803#M4728</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-05-26T18:41:01Z</dc:date>
    </item>
  </channel>
</rss>

