<?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: Identifying number of rows associated with a subgroup in a free text dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862175#M340549</link>
    <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I get:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;179 data want;&lt;BR /&gt;180 set B2016_21;&lt;BR /&gt;181 Bulletin + missing(compress(lag(TEXT),'0D0A0900A0'x));&lt;BR /&gt;-&lt;BR /&gt;400&lt;BR /&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;&lt;P&gt;182 run;&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;181:31&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.WANT may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 2 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;183 data want;&lt;BR /&gt;184 set B2016_21;&lt;BR /&gt;185 Bulletin + missing(compress(lag(Bulletin),'0D0A0900A0'x));&lt;BR /&gt;-&lt;BR /&gt;400&lt;BR /&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;&lt;P&gt;186 run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.WANT may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 1 variables.&lt;BR /&gt;WARNING: Data set WORK.WANT was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2023 17:39:32 GMT</pubDate>
    <dc:creator>Kouros</dc:creator>
    <dc:date>2023-03-03T17:39:32Z</dc:date>
    <item>
      <title>Identifying number of rows associated with a subgroup in a free text dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862056#M340494</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a big file (&amp;gt;3.5 mil rows) describing weather. The data is coming as a single variable and it is a succession of filled rows with text broken by an empty row when weather for a new location is being described. There is no set number of rows for a particular block of data. There are also blocks of information not necessarily related to a particular location. The number of rows in a particular block can go from 1 to couple of 10s of rows. I would like to assign a unique identifier to each block and to then identify the number of rows in each block. It looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA&lt;BR /&gt;WHISTLER.&lt;BR /&gt;TODAY..MAINLY CLOUDY. CHANCE OF SHOWERS. HIGH 19. UV INDEX 4.8 OR&lt;BR /&gt;MODERATE.&lt;BR /&gt;TONIGHT..CLOUDY WITH SHOWERS LIKELY. LOW 10.&lt;BR /&gt;FRIDAY..CLOUDY WITH SUNNY PERIODS. CHANCE OF A SHOWER. HIGH 24.&lt;BR /&gt;PROBABILITY OF PRECIPITATION IN PERCENT 60 TODAY. 70 TONIGHT AND&lt;BR /&gt;40 FRIDAY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUNSHINE COAST.&lt;BR /&gt;TODAY..CLOUDY WITH SHOWERS LIKELY. HIGH 18. UV INDEX 4.6 OR MODERAT&lt;BR /&gt;TONIGHT..CLOUDY WITH SHOWERS LIKELY. LOW 12.&lt;BR /&gt;FRIDAY..SUNNY WITH CLOUDY PERIODS. CHANCE OF A SHOWER. HIGH 22.&lt;BR /&gt;PROBABILITY OF PRECIPITATION IN PERCENT 70 TODAY. 70 TONIGHT AND&lt;BR /&gt;40 FRIDAY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EAST VANCOUVER ISLAND.&lt;BR /&gt;TODAY..MAINLY CLOUDY. SHOWERS LIKELY. WINDY NEAR THE STRAIT. HIGH 1&lt;BR /&gt;UV INDEX 4.8 OR MODERATE.&lt;BR /&gt;TONIGHT..CLOUDY WITH SHOWERS LIKELY. WINDY NEAR THE STRAIT. LOW 12.&lt;BR /&gt;FRIDAY..SUNNY WITH CLOUDY PERIODS. CHANCE OF A SHOWER NORTHERN&lt;BR /&gt;SECTIONS. HIGH 21 TO 24.&lt;BR /&gt;PROBABILITY OF PRECIPITATION IN PERCENT 70 TODAY. 70 TONIGHT AND&lt;BR /&gt;40 FRIDAY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WEST VANCOUVER ISLAND - COASTAL SECTIONS.&lt;BR /&gt;TODAY..CLOUDY WITH SHOWERS. WIND SOUTHEAST 40 TO 60 KM/H OVER&lt;BR /&gt;NORTHERN SECTIONS. HIGH 16. UV INDEX 4.8 OR MODERATE.&lt;BR /&gt;TONIGHT..CLOUDY WITH SHOWERS. WIND SOUTHEAST 40 TO 60 KM/H OVER&lt;BR /&gt;NORTHERN SECTIONS EASING THIS EVENING. LOW 12.&lt;BR /&gt;FRIDAY..CLOUDY WITH SUNNY PERIODS. CHANCE OF A MORNING SHOWER.&lt;BR /&gt;HIGH 18.&lt;BR /&gt;PROBABILITY OF PRECIPITATION IN PERCENT 100 TODAY. 90 TONIGHT AND&lt;BR /&gt;40 FRIDAY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WEST VANCOUVER ISLAND - INLAND SECTIONS.&lt;BR /&gt;TODAY..CLOUDY WITH A FEW SHOWERS. HIGH 18. UV INDEX 4.7 OR MODERATE&lt;BR /&gt;TONIGHT..CLOUDY WITH A FEW SHOWERS. LOW 12.&lt;BR /&gt;FRIDAY..CLOUDY WITH SUNNY PERIODS. CHANCE OF A SHOWER MAINLY NORTHE&lt;BR /&gt;SECTIONS. HIGH 24.&lt;BR /&gt;PROBABILITY OF PRECIPITATION IN PERCENT 80 TODAY. 80 TONIGHT AND&lt;BR /&gt;40 FRIDAY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NORTH VANCOUVER ISLAND.&lt;BR /&gt;TODAY..CLOUDY WITH SHOWERS. WIND SOUTHEAST 40 TO 60 KM/H. HIGH 16.&lt;BR /&gt;UV INDEX 4.5 OR MODERATE.&lt;BR /&gt;TONIGHT..CLOUDY WITH SHOWERS. SOUTHEAST 40 TO 60 KM/H EASING THIS&lt;BR /&gt;EVENING. LOW 11.&lt;BR /&gt;FRIDAY..CLOUDY WITH SUNNY PERIODS. CHANCE OF SHOWERS. HIGH 17.&lt;BR /&gt;PROBABILITY OF PRECIPITATION IN PERCENT 90 TODAY. 90 TONIGHT AND&lt;BR /&gt;60 FRIDAY.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 03 Mar 2023 01:12:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862056#M340494</guid>
      <dc:creator>Kouros</dc:creator>
      <dc:date>2023-03-03T01:12:39Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying number of rows associated with a subgroup in a free text dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862065#M340503</link>
      <description>&lt;P&gt;It is not clear from your data dump what is the name of the dataset or the name of the variable with the text.&lt;/P&gt;
&lt;P&gt;So lets just assume the dataset is named HAVE and the variable is named TEXT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  group + missing(text);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That will put number the groups starting with 0. The blank line will be the beginning of a new group.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 02:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862065#M340503</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-03T02:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying number of rows associated with a subgroup in a free text dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862146#M340541</link>
      <description>&lt;P&gt;It doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I found a solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, I identify the blank row because with the Len() function will give me the value of 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I use the lag1 function for this newly created variable to identify the start of a new block of text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Knowing the beginning of the new block, define a new variable ID = _N_ where lag1(Len()) = 1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then using retain statement assign the same _N_ value to the rest of each block's rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Identifying the number of rows in each block then becomes easy,&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 15:54:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862146#M340541</guid>
      <dc:creator>Kouros</dc:creator>
      <dc:date>2023-03-03T15:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying number of rows associated with a subgroup in a free text dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862147#M340542</link>
      <description>&lt;P&gt;The LENGTH() function will return 1 for an empty value, but also for a value with only one character.&amp;nbsp; Note that it might be that the empty values are not actually empty, but instead of a single non-blank character. perhaps a Carriage Return ('0D'x) or and LineFeed ('0A'x) or some other invisible character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The LENGTHN() function will return 0 for an empty value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You seem to have split the simple SUM STATEMENT used in my example back into its pieces.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try testing if the previous line only has spaces, cr, lf, tab or non-breaking spaces to indicate the start of a new group.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  group + missing(compress(lag(TEXT),'0D0A0900A0'x));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That will start the numbering at the line AFTER the blank line.&amp;nbsp; Since the first call to LAG() always returns empty value since nothing has yet been given to it to remember it also means it will start numbering from 1 instead of 0.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 16:01:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862147#M340542</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-03T16:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying number of rows associated with a subgroup in a free text dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862175#M340549</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I get:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;179 data want;&lt;BR /&gt;180 set B2016_21;&lt;BR /&gt;181 Bulletin + missing(compress(lag(TEXT),'0D0A0900A0'x));&lt;BR /&gt;-&lt;BR /&gt;400&lt;BR /&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;&lt;P&gt;182 run;&lt;/P&gt;&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by:&lt;BR /&gt;(Line):(Column).&lt;BR /&gt;181:31&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.WANT may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 2 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.03 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;183 data want;&lt;BR /&gt;184 set B2016_21;&lt;BR /&gt;185 Bulletin + missing(compress(lag(Bulletin),'0D0A0900A0'x));&lt;BR /&gt;-&lt;BR /&gt;400&lt;BR /&gt;ERROR 400-185: The SUM statement requires numeric expression.&lt;/P&gt;&lt;P&gt;186 run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.WANT may be incomplete. When this step was stopped there were 0&lt;BR /&gt;observations and 1 variables.&lt;BR /&gt;WARNING: Data set WORK.WANT was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2023 17:39:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862175#M340549</guid>
      <dc:creator>Kouros</dc:creator>
      <dc:date>2023-03-03T17:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying number of rows associated with a subgroup in a free text dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862178#M340550</link>
      <description>&lt;P&gt;You must already have a variable named BULLETIN and it is a CHARACTER variable.&lt;/P&gt;
&lt;P&gt;To use the SUM statement (really to use the RETAIN feature that it implies) you need to sum into a NEW NUMERIC variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input text $20.;
cards;
asdfs
asdfasd

sdfas
adsfa
adsfas
;

data have;
  set have;
  group + missing(lag(text));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1677865506657.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81046iC2B88E3CE2AB6C23/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1677865506657.png" alt="Tom_0-1677865506657.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>Fri, 03 Mar 2023 17:45:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862178#M340550</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-03T17:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying number of rows associated with a subgroup in a free text dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862492#M340694</link>
      <description>Thank you Tim,&lt;BR /&gt;&lt;BR /&gt;Yes, hat worked perfectly.&lt;BR /&gt;&lt;BR /&gt;What is this group statement? My SAS version, it is not colored as a special word, but it is kept as text, and I cannot find it in the SAS Help.</description>
      <pubDate>Mon, 06 Mar 2023 15:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862492#M340694</guid>
      <dc:creator>Kouros</dc:creator>
      <dc:date>2023-03-06T15:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying number of rows associated with a subgroup in a free text dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862502#M340703</link>
      <description>&lt;P&gt;GROUP is just the name of the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is a SUM statement.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1dfiqj146yi2cn1maeju9wo7ijs.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1dfiqj146yi2cn1maeju9wo7ijs.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then syntax is VARIABLE + EXPRESSION ;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 15:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862502#M340703</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-06T15:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Identifying number of rows associated with a subgroup in a free text dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862673#M340764</link>
      <description>Thank you!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Mar 2023 15:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Identifying-number-of-rows-associated-with-a-subgroup-in-a-free/m-p/862673#M340764</guid>
      <dc:creator>Kouros</dc:creator>
      <dc:date>2023-03-07T15:13:56Z</dc:date>
    </item>
  </channel>
</rss>

