<?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: SAS Scan in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405973#M98793</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89940"&gt;@jhh197&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;This also helped Thank you so much for quick response&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It also creates enumerated macro variables with values of each word.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Oct 2017 14:36:21 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2017-10-20T14:36:21Z</dc:date>
    <item>
      <title>SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405858#M98754</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a macro &amp;amp;u = 6,22,5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.) How do I detect from macro u where there is a comma&amp;nbsp; %if scan(&amp;amp;x,',') &amp;gt; 0 will this work ?&lt;/P&gt;&lt;P&gt;2.) How do I count the number of words from the string u ( Answer should be )&lt;/P&gt;&lt;P&gt;3.) How do I extract 6 from string u and 22 from string u and assign that to macro variable and 5 from string u and assign it to macro variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please Can anyone help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 03:45:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405858#M98754</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2017-10-20T03:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405860#M98756</link>
      <description>&lt;P&gt;1. It's not clear what you want here&lt;/P&gt;
&lt;P&gt;2. COUNTW/COUNT&lt;/P&gt;
&lt;P&gt;3. %SCAN or SCAN&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 03:57:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405860#M98756</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-20T03:57:46Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405862#M98758</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have macro variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let u = 6,22,5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want a macro code to check whether comma exists in the macro u if yes then I want a syntax to count macro u ( Answer should be 3 in above case )&lt;/P&gt;&lt;P&gt;next I want syntax &amp;nbsp;to extract 6 into one macro&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;22 into one macro&lt;/P&gt;&lt;P&gt;5 into one macro variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 04:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405862#M98758</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2017-10-20T04:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405863#M98759</link>
      <description>&lt;P&gt;I would use FIND or INDEX personally to see if there's a comma.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're having trouble with that feel free to post your code and log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 04:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405863#M98759</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-20T04:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405866#M98760</link>
      <description>Yes&lt;BR /&gt;I used %let x = index(&amp;amp;u, ',');&lt;BR /&gt;% put &amp;amp;x but it's not resolved&lt;BR /&gt;Error :the quoted string currently being processed became more than 262 characters long . The string might have unbalanced quotation marks quotation&lt;BR /&gt;&lt;BR /&gt;For count I tried&lt;BR /&gt;% let h = %sysfunc(countw(&amp;amp;x,','));&lt;BR /&gt;%put &amp;amp;h;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Oct 2017 04:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405866#M98760</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2017-10-20T04:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405867#M98761</link>
      <description>Sorry I used this macro for count&lt;BR /&gt;&lt;BR /&gt;%let h= %sysfunc(countw(&amp;amp;u,','));&lt;BR /&gt;%put &amp;amp;h;</description>
      <pubDate>Fri, 20 Oct 2017 04:25:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405867#M98761</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2017-10-20T04:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405868#M98762</link>
      <description>&lt;P&gt;&lt;A href="http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=p1n2i0ewaj1zian1ria5579z1zjh.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=p1n2i0ewaj1zian1ria5579z1zjh.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 04:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405868#M98762</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-20T04:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405893#M98768</link>
      <description>&lt;P&gt;Why not, as a way out there thought, use Base SAS for processing your data?&lt;/P&gt;
&lt;PRE&gt;data _null_;
  comma=ifc(index("&amp;amp;x.",",")&amp;gt;0,"Y","N");
  call symput('commayn',comma);
  call symput(countw("&amp;amp;x.",",");
  do i=1 to countw("&amp;amp;x.",",");
    call symput('newm'||strip(put(i,best.)),scan("&amp;amp;x.",i,","));
  end;
run;&lt;/PRE&gt;
&lt;P&gt;To be honest its rarely a good idea to have lists of items in macro variables, or be processing these lists in such a way - your code will become overly complex and hard to maintain with no real benefit.&amp;nbsp; Put data in datasets and use Base SAS to manipulate it - macro is for creating generically derived Base SAS code, not for data processing.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 08:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405893#M98768</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-20T08:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405895#M98770</link>
      <description>&lt;P&gt;I did not find any way to use &lt;STRONG&gt;macro functions&lt;/STRONG&gt;, to resolve your issue, that is - dealing with a list of values separated by &lt;STRONG&gt;comma&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can either use a list of values separated by a blank/space and use method quoted by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;or you can use sas datastep to do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let u = 6,22,5;

%macro test;
    data _NULL_;
        comma_position = index("&amp;amp;u",',');
        count = countw("&amp;amp;u");
        call symput('Comma_Position',left(comma_position));
        call symput('Count',strip(count));
   run;
   %put First Comma is in position &amp;amp;comma_position;
   %put The list {&amp;amp;u} contains &amp;amp;count Members;
%mend test;
%test;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 08:54:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405895#M98770</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-10-20T08:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405958#M98788</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89940"&gt;@jhh197&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a macro &amp;amp;u = 6,22,5&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.) How do I detect from macro u where there is a comma&amp;nbsp; %if scan(&amp;amp;x,',') &amp;gt; 0 will this work ?&lt;/P&gt;
&lt;P&gt;2.) How do I count the number of words from the string u ( Answer should be )&lt;/P&gt;
&lt;P&gt;3.) How do I extract 6 from string u and 22 from string u and assign that to macro variable and 5 from string u and assign it to macro variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please Can anyone help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to quote the commas in your string so they don't cause trouble.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;32         %macro splitstring(arg);
33            %local i w;
34            %do i = 1 %to %sysfunc(countw(%superQ(u),%str(,)));
35               %local w&amp;amp;i;
36               %let w&amp;amp;i = %scan(%superq(u),&amp;amp;i);
37               %end;
38            %let i = %eval(&amp;amp;i-1);
39            %put _local_;
40            %mend;
41         %splitstring(%bquote(&amp;amp;u));
SPLITSTRING ARG &amp;#4;6&amp;#30;22&amp;#30;5&amp;#8;
SPLITSTRING I 3
SPLITSTRING W 
SPLITSTRING W1 6
SPLITSTRING W2 22
SPLITSTRING W3 5
42         %splitstring((&amp;amp;u));
SPLITSTRING ARG (6,22,5)
SPLITSTRING I 3
SPLITSTRING W 
SPLITSTRING W1 6
SPLITSTRING W2 22
SPLITSTRING W3 5&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 14:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405958#M98788</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-10-20T14:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405965#M98791</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;Thank you this worked for detecting comma position and counting the arguments&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 14:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405965#M98791</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2017-10-20T14:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405972#M98792</link>
      <description>&lt;P&gt;This also helped Thank you so much for quick response&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 14:33:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405972#M98792</guid>
      <dc:creator>jhh197</dc:creator>
      <dc:date>2017-10-20T14:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Scan</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405973#M98793</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/89940"&gt;@jhh197&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;This also helped Thank you so much for quick response&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It also creates enumerated macro variables with values of each word.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 14:36:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Scan/m-p/405973#M98793</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-10-20T14:36:21Z</dc:date>
    </item>
  </channel>
</rss>

