<?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: LOOPING OVER STRING VALUES IN DATASET in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544146#M7810</link>
    <description>You should look up the ANYALPHA, ANYDIGIT functions. You can roll your own of course, but it's much easier to use the pre-written ones unless you have a really customized requirement.</description>
    <pubDate>Tue, 19 Mar 2019 02:26:08 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-03-19T02:26:08Z</dc:date>
    <item>
      <title>LOOPING OVER STRING VALUES IN DATASET</title>
      <link>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544134#M7804</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to loop over a string and assign a value&amp;nbsp; based on whether the value is a number or a character e.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;length Newcat $ 20;&lt;BR /&gt;retain NewCat;&lt;BR /&gt;Ref="123ABC";&lt;BR /&gt;do i=1 to length(Ref);&lt;BR /&gt;val=substr(Ref,i,1);&lt;BR /&gt;if val in ("1","2","3","4","5","6","7","8","9") then preCat="0"; else preCat="A";&lt;BR /&gt;NewCat=catt(NewCat,preCat);&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This correctly solves to NewCat="000AAA". The issue is that I need this to work in a data step on a dataset with a number of rows&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data t1;&lt;BR /&gt;set Work.Data;&lt;BR /&gt;do i=1 to length(Ref);&lt;BR /&gt;length Newcat $ 20;&lt;BR /&gt;val=substr(Ref,i,1);&lt;BR /&gt;if val in ("1","2","3","4","5","6","7","8","9") then preCat="0"; else preCat="A";&lt;BR /&gt;NewCat=catt(NewCat,preCat);&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas would be massively appreciated. Thanks in advance. D.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 01:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544134#M7804</guid>
      <dc:creator>dm2018</dc:creator>
      <dc:date>2019-03-19T01:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: LOOPING OVER STRING VALUES IN DATASET</title>
      <link>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544137#M7805</link>
      <description>&lt;P&gt;Did you try your program?&amp;nbsp; A data step like that will process every observation. That is how the data step works.&lt;/P&gt;
&lt;P&gt;What is it NOT doing that you need?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 01:37:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544137#M7805</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-19T01:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: LOOPING OVER STRING VALUES IN DATASET</title>
      <link>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544138#M7806</link>
      <description>&lt;P&gt;Ah, believe it may be the sequencing of the do loop. Values are being assigned to NewCat, but they are not correct as per the Ref on the corresponding row. Will look into this unless you have any ideas? Many thanks for the reply. D.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 01:40:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544138#M7806</guid>
      <dc:creator>dm2018</dc:creator>
      <dc:date>2019-03-19T01:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: LOOPING OVER STRING VALUES IN DATASET</title>
      <link>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544139#M7807</link>
      <description>&lt;P&gt;Post examples of the values that you think are not processed correctly.&lt;/P&gt;
&lt;P&gt;If you suspect the DO loop is doing something strange then put some PUT statements in it and check out what it actually happening.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 01:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544139#M7807</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-19T01:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: LOOPING OVER STRING VALUES IN DATASET</title>
      <link>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544141#M7808</link>
      <description>&lt;P&gt;Thanks. Looks like I need to clear NewCat:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BusinessNumber Newcat&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i val preCat&lt;BR /&gt;123ABC&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;000AAA&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;7 C A&lt;BR /&gt;ABC123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;000AAAAAA000&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 7 3 0&lt;BR /&gt;1A2B3C&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;000AAAAAA0000A0A0A 7 C A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not 100% sure on how to do this but thanks, getting closer! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 01:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544141#M7808</guid>
      <dc:creator>dm2018</dc:creator>
      <dc:date>2019-03-19T01:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: LOOPING OVER STRING VALUES IN DATASET</title>
      <link>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544142#M7809</link>
      <description>Apologies! I've got it, for some reason I'd been retaining NewCat although hadn't show this on the example above. Thanks for your help. Much appreciated. Regards, D.</description>
      <pubDate>Tue, 19 Mar 2019 02:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544142#M7809</guid>
      <dc:creator>dm2018</dc:creator>
      <dc:date>2019-03-19T02:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: LOOPING OVER STRING VALUES IN DATASET</title>
      <link>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544146#M7810</link>
      <description>You should look up the ANYALPHA, ANYDIGIT functions. You can roll your own of course, but it's much easier to use the pre-written ones unless you have a really customized requirement.</description>
      <pubDate>Tue, 19 Mar 2019 02:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544146#M7810</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-19T02:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: LOOPING OVER STRING VALUES IN DATASET</title>
      <link>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544259#M7820</link>
      <description>&lt;P&gt;No loop needed:&lt;/P&gt;
&lt;PRE&gt;data example;
   x='1A2B3C';
   y=translate(x,'000000000AAAAAAAAAAAAAAAAAAAAAAAAAA',
                 '123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ');
run;&lt;/PRE&gt;
&lt;P&gt;If your variable may contain lowercase letters then use Upcase(variablename) instead of the X as the first parameter.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2019 15:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/LOOPING-OVER-STRING-VALUES-IN-DATASET/m-p/544259#M7820</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-19T15:06:28Z</dc:date>
    </item>
  </channel>
</rss>

