<?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: Scan isn't working in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859840#M37967</link>
    <description>Thanks for responding. It's necessary for me to use macro language in my code to reduce the complexity as i've more than 5 columns are of same type of values in my table and i do have terms less than 12.</description>
    <pubDate>Tue, 21 Feb 2023 05:36:46 GMT</pubDate>
    <dc:creator>Vasundha</dc:creator>
    <dc:date>2023-02-21T05:36:46Z</dc:date>
    <item>
      <title>Scan isn't working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859834#M37965</link>
      <description>&lt;P&gt;Hello Experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd be grateful if you could assist me on this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've a table with some columns named Code1-Code5. In these columns I've values separated with colon (:). So, for that I've written a macro .&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's it is.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro abc;
Data xyz;
Set xyz;
%do i =1 %to 5;
Code_C&amp;amp;i. = scan(Code&amp;amp;I., 12, ' : ') ;
%end;
run;
%mend abc;
%abc

In this code, the new variables are getting created but there are no values in it. Im having blank values in them. 
I've no clue why it isn't providing values the way it is supposed to. Please help me out on this. &lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2023 04:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859834#M37965</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2023-02-21T04:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Scan isn't working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859838#M37966</link>
      <description>&lt;P&gt;Your code works and does what you're asking it to do but.... don't use macro language if not necessary.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your code you're extracting the 12th term. If there are less than 12 terms then the result will be missing.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_1-1676956455392.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80645i6959232A766CDB0D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_1-1676956455392.png" alt="Patrick_1-1676956455392.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Converting your code to data step syntax only:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data xyz;
  length code1 - code5 $30;
  code1='aa:bb';
  code4='a:a:a:a:a:a:a:a:a:a:B:C:D:E';
run;

data xyz;
  set xyz;
  array _code {*} code1 - code5;
  array code_C {5} $30;
  do _i=1 to dim(_code);
    code_C[_i] = scan(_code[_i], 12, ' : ');
  end;
  drop _i;
run;

proc print data=xyz;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_2-1676956825190.png" style="width: 694px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/80646iAB5CFF19597A4B92/image-dimensions/694x59?v=v2" width="694" height="59" role="button" title="Patrick_2-1676956825190.png" alt="Patrick_2-1676956825190.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 05:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859838#M37966</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-02-21T05:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Scan isn't working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859840#M37967</link>
      <description>Thanks for responding. It's necessary for me to use macro language in my code to reduce the complexity as i've more than 5 columns are of same type of values in my table and i do have terms less than 12.</description>
      <pubDate>Tue, 21 Feb 2023 05:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859840#M37967</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2023-02-21T05:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Scan isn't working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859842#M37969</link>
      <description>I get it what I require instead of 12 I should use 1. That's my bad. Anyways, thankyou.</description>
      <pubDate>Tue, 21 Feb 2023 05:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859842#M37969</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2023-02-21T05:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Scan isn't working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859859#M37970</link>
      <description>&lt;P&gt;You DO NOT NEED a macro. Expanding an array is easier than expanding macro code.&lt;/P&gt;
&lt;P&gt;The list of variables can be determined in a preceding step and stored in a&amp;nbsp;&lt;EM&gt;macro variable&lt;/EM&gt;, but you positively do not need a &lt;EM&gt;macro&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't be obsessed with (ab)using the macro language just because it's there.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 08:07:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859859#M37970</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-21T08:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: Scan isn't working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859864#M37971</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/420851"&gt;@Vasundha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I get it what I require instead of 12 I should use 1. That's my bad. Anyways, thankyou.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If it's the first term you're after then yes, you need 1 ...and that's why I've created such sample data to show you what happens.&lt;/P&gt;
&lt;P&gt;And about macro language: I've shared with you fully working data step code that demonstrates that you don't need macro language.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 08:42:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859864#M37971</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-02-21T08:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Scan isn't working</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859868#M37972</link>
      <description>&lt;P&gt;By the way your SCAN is including SPACE as a delimiter. So If one of your values in delimited list includes a space that is counted as well. If you do not want to use a space as a delimiter do not include them in the third parameter&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of&lt;/P&gt;
&lt;PRE&gt;Code_C&amp;amp;i. = scan(Code&amp;amp;I., 12, ' : ') ;&lt;/PRE&gt;
&lt;P&gt;to not include space as delimiter&lt;/P&gt;
&lt;PRE&gt;Code_C&amp;amp;i. = scan(Code&amp;amp;I., 12, ':') ;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Data as an example is helpful because otherwise we have to make guesses as to what valid values may look like and quite often those guesses can be wrong.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/420851"&gt;@Vasundha&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello Experts,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd be grateful if you could assist me on this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've a table with some columns named Code1-Code5. In these columns I've values separated with colon (:). So, for that I've written a macro .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's it is.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro abc;
Data xyz;
Set xyz;
%do i =1 %to 5;
Code_C&amp;amp;i. = scan(Code&amp;amp;I., 12, ' : ') ;
%end;
run;
%mend abc;
%abc

In this code, the new variables are getting created but there are no values in it. Im having blank values in them. 
I've no clue why it isn't providing values the way it is supposed to. Please help me out on this. &lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 08:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Scan-isn-t-working/m-p/859868#M37972</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-02-21T08:55:58Z</dc:date>
    </item>
  </channel>
</rss>

