<?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: Delimiter in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817073#M34428</link>
    <description>&lt;P&gt;Replying to All and posting it again.&lt;/P&gt;&lt;PRE&gt;String_variable
Abcdefghi+7/edfiklhopr+9
Jakdkopiqwe++9/ajsjsjajsj++10/ghakakak++12/hwjwjwnnw++1&lt;BR /&gt;&lt;BR /&gt;Required Output:&lt;BR /&gt;Count_1plus  count_2plus&lt;BR /&gt;2                0&lt;BR /&gt;0                4&lt;BR /&gt;&lt;BR /&gt;Patrick's code working nicely but it is giving me the output like this and considering ++ as 2 single ++ instead of considering only 1 +. Please help me on achieving the required output which I mentioned above. Thankyou.&lt;BR /&gt;The Output I got :&lt;/PRE&gt;&lt;PRE&gt;Count_1plus  count_2plus&lt;/PRE&gt;&lt;PRE&gt;2                0&lt;/PRE&gt;&lt;PRE&gt;4               4&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Jun 2022 13:41:55 GMT</pubDate>
    <dc:creator>Vasundha</dc:creator>
    <dc:date>2022-06-08T13:41:55Z</dc:date>
    <item>
      <title>Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817008#M34413</link>
      <description>Hi Everyone,&lt;BR /&gt;A newbie needs your help. May I know how to find the count of a specific delimiter in a string variable column.&lt;BR /&gt;For instance,&lt;BR /&gt;String = gfhabciklm+7/refghibklr+8/abcdefghij+9;&lt;BR /&gt;I need the count of " +" only In this string irrespective of other delimiter.&lt;BR /&gt;Looking forward to getting some support from you guys. Thankyou.</description>
      <pubDate>Wed, 08 Jun 2022 09:13:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817008#M34413</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T09:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817019#M34414</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/420851"&gt;@Vasundha&lt;/a&gt;&amp;nbsp;Welcome to the SAS Communities.&lt;/P&gt;
&lt;P&gt;Here you go:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo;
 have='String = gfhabciklm+7/refghibklr+8/abcdefghij+9;';
 count_plus=countc(have,'+');
run;

proc print data=demo;
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_0-1654685120389.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72065i4E5D324BE6AFB3CC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1654685120389.png" alt="Patrick_0-1654685120389.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you didn't ask specifically but just because you were mentioning the term "delimiter" here how you could read such a string into SAS variables using the plus sign as delimiter.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data demo2;
  infile datalines truncover dsd dlm='+';
  input (var1-var5) (:$40.);
  datalines4;
gfhabciklm+7/refghibklr+8/abcdefghij+9;
;;;;
proc print data=demo2;
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_0-1654685394033.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72066i7F618CBE090FC400/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1654685394033.png" alt="Patrick_0-1654685394033.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>Wed, 08 Jun 2022 10:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817019#M34414</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-06-08T10:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817024#M34415</link>
      <description>Hi Patrick, thankyou for providing the result but, i used the same concept. I've got for some fields the count is blank even though it has a (+) symbol in the string value. And more over I've a long value in the same column which has 7 +'s but when I used your concept it is showing only the count is 1.&lt;BR /&gt;I created such values in a column in excel file and importing that file to sas.</description>
      <pubDate>Wed, 08 Jun 2022 11:07:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817024#M34415</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T11:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817026#M34416</link>
      <description>&lt;P&gt;I'm rather certain that the code I've provided will work as desired. If it's not working for you then eventually your source string is truncated.&lt;/P&gt;
&lt;P&gt;Ideally provide some sample data or even the Excel as an attachment (many people won't open this ...but I will) where things are not working for you. It's kind-of impossible to address your problem without seeing your code and being able to replicate what you describe.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 11:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817026#M34416</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-06-08T11:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817027#M34417</link>
      <description>Yes, you're so right. My data has been truncated and i figured out that some values has ++'s so, I added additional variable for ++'s in your code but, despite of picking the ++'s count, it is picking single +'s count only for both the count variables. Could you help me on that to achieve this. Thankyou.</description>
      <pubDate>Wed, 08 Jun 2022 11:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817027#M34417</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T11:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817030#M34418</link>
      <description>&lt;P&gt;Sure. So what exactly do you need? Count consecutive ++ only once or define a delimiter that deals with repeated ++.&lt;/P&gt;
&lt;P&gt;If it's the delimiter bit: Would a repeated ++ be a single delimiter or indicate there the is just no value between the plusses?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide a sample string and then show the desired result.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 11:25:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817030#M34418</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-06-08T11:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817033#M34419</link>
      <description>&lt;P&gt;Sure here it is,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;String_variable
Abcdefghi+7/edfiklhopr+9
Jakdkopiqwe++9/ajsjsjajsj++10/jajsjakam++4/hefghikqp++1&lt;/PRE&gt;&lt;P&gt;I need two count variables for + and ++&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;Count_plus1&amp;nbsp; &amp;nbsp;count_plus2&lt;/P&gt;&lt;P&gt;2&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; &amp;nbsp; 4&lt;/P&gt;&lt;P&gt;And if there's no ++ the count_plus2 should be 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 11:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817033#M34419</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T11:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817038#M34420</link>
      <description>&lt;P&gt;If you can be certain that you ever only get one or two consecutive plusses then below code should work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the number of consecutive plusses can vary and is "undefined" then things will become quickly quite a bit more involved and require more advanced coding.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input string :$60.;
  datalines4;
Abcdefghi+7/edfiklhopr+9
Jakdkopiqwe++9/ajsjsjajsj++10/jajsjakam++4/hefghikqp++1
;;;;
data want;
  set have;
  count_all=countc(string,'+','it');
  count_2plus=count(string,'++','it');
  count_1plus=count_all-(count_2plus*2);
  drop count_all;
run;
proc print data=want;
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_0-1654689393135.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72069i720E82A6F14445A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1654689393135.png" alt="Patrick_0-1654689393135.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 11:57:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817038#M34420</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-06-08T11:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817044#M34421</link>
      <description>Thank you. I've got blank values for count_1plus.</description>
      <pubDate>Wed, 08 Jun 2022 12:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817044#M34421</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T12:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817049#M34422</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;Thank you. I've got blank values for count_1plus.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not sure what you mean by that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "best" and quickest way to get what you need: Provide to us sample data in the form of a working data have step same as I used in my last post. Try for this data have step to create representative sample data covering all the real cases you're dealing with. Then show us based on the sample data the desired outcome and describe the logic required to get to this outcome. &lt;BR /&gt;....and often people also appreciate if you share the code you've already tried to make this work. Even if such code doesn't work yet, it does help to understand your current thought process as well as your current level of SAS coding skills so people can provide answers suitable to your level.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 12:14:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817049#M34422</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-06-08T12:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817050#M34423</link>
      <description>Please make a bit change in the concept. Include 0 in count_2plus only if there's no ++, not for count_1plus.</description>
      <pubDate>Wed, 08 Jun 2022 12:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817050#M34423</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T12:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817052#M34424</link>
      <description>&lt;P&gt;Please read my last post. You need to be very clear and best provide representative sample data and desired result.&lt;/P&gt;
&lt;P&gt;It's already late in my part of the world so signing off - but I'm sure someone else will pick-up from here.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 12:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817052#M34424</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-06-08T12:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817053#M34425</link>
      <description>Alright. Thank you very much.</description>
      <pubDate>Wed, 08 Jun 2022 12:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817053#M34425</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T12:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817073#M34428</link>
      <description>&lt;P&gt;Replying to All and posting it again.&lt;/P&gt;&lt;PRE&gt;String_variable
Abcdefghi+7/edfiklhopr+9
Jakdkopiqwe++9/ajsjsjajsj++10/ghakakak++12/hwjwjwnnw++1&lt;BR /&gt;&lt;BR /&gt;Required Output:&lt;BR /&gt;Count_1plus  count_2plus&lt;BR /&gt;2                0&lt;BR /&gt;0                4&lt;BR /&gt;&lt;BR /&gt;Patrick's code working nicely but it is giving me the output like this and considering ++ as 2 single ++ instead of considering only 1 +. Please help me on achieving the required output which I mentioned above. Thankyou.&lt;BR /&gt;The Output I got :&lt;/PRE&gt;&lt;PRE&gt;Count_1plus  count_2plus&lt;/PRE&gt;&lt;PRE&gt;2                0&lt;/PRE&gt;&lt;PRE&gt;4               4&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jun 2022 13:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817073#M34428</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T13:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817077#M34429</link>
      <description>&lt;P&gt;Post data as a data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input String_variable $80.;
cards;
Abcdefghi+7/edfiklhopr+9
Jakdkopiqwe++9/ajsjsjajsj++10/ghakakak++12/hwjwjwnnw++1
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Post code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  count1 = countc(string,'+');
  count2 = count(string,'++');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Show results:&lt;/P&gt;
&lt;PRE&gt;Obs    string                                                     count1    count2

 1     Abcdefghi+7/edfiklhopr+9                                      2         0
 2     Jakdkopiqwe++9/ajsjsjajsj++10/ghakakak++12/hwjwjwnnw++1       8         4
&lt;/PRE&gt;
&lt;P&gt;If the results are not what you want then explain what you want.&lt;/P&gt;
&lt;P&gt;For example you seem to think there are ZERO plus signs in that second string, but as the results show there are clearly 8 plus signs there.&amp;nbsp; Why did you think there should be zero?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 13:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817077#M34429</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-08T13:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817082#M34430</link>
      <description>&lt;PRE&gt;Required results:

Obs    string                                                                                        count1    count2

 1     Abcdefghi+7/edfiklhopr+9                                                                         2         0
 2     Jakdkopiqwe++9/ajsjsjajsj++10/ghakakak++12/hwjwjwnnw++1                                          0         4&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jun 2022 13:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817082#M34430</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T13:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817083#M34431</link>
      <description>It's because of the plus is repeating twice not just once. That's why I asked zero. Please have a look at the required output which I replied to you. Thankyou.</description>
      <pubDate>Wed, 08 Jun 2022 13:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817083#M34431</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T13:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817086#M34432</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;It's because of the plus is repeating twice not just once. That's why I asked zero. Please have a look at the required output which I replied to you. Thankyou.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you only what to count plus signs that are not next to other plus signs?&lt;/P&gt;
&lt;P&gt;You could perhaps try using regular expressions to do something that complex.&lt;/P&gt;
&lt;P&gt;But in this limited case just get the double plus signs out of the way before counting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;countc(tranwrd(string,'++',' '),'+')&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS If you are trying to parse expressions in some language like C where + and ++ are different operators then SAS is probably not the language to use. There are languages that are designed for building parsers and compilers.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 14:16:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817086#M34432</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-08T14:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817088#M34434</link>
      <description>&lt;P&gt;My point is if the string value has 1 plus sign followed by slash / then consider count1 as 1. If the string value has 2 plus sign followed by slash / then consider count1 as 1. Otherwise 0's.&lt;/P&gt;&lt;P&gt;Consider this output:&lt;/P&gt;&lt;PRE&gt;Required result:

Obs    string                                                    count1    count2

 1     Abcdefghi+7/edfiklhopr+9                                    2         0
 2     Jakdkopiqwe++9/ajsjsjajsj++10/ghakakak++12/hwjwjwnnw++1     0        4&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 14:18:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817088#M34434</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T14:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Delimiter</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817091#M34437</link>
      <description>It's not a operator, just a character in my string value.</description>
      <pubDate>Wed, 08 Jun 2022 14:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Delimiter/m-p/817091#M34437</guid>
      <dc:creator>Vasundha</dc:creator>
      <dc:date>2022-06-08T14:20:16Z</dc:date>
    </item>
  </channel>
</rss>

