<?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: How to get observation from between the segment in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918698#M361891</link>
    <description>&lt;P&gt;Thank you for supplying your sample data as a working DATA step.&amp;nbsp; I don't see a similar sample of the corresponding expected output, but I suspect this is what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _1;
infile datalines dsd truncover;
INPUT Level:8. F_there:$1. Blank_90:8.;
DATALINES ;
1,x,20
2,x,20
3,F,29
3,F,
4,F,
4,s,90
5,s,
5,s,91
3,F,90
3,s,3
4,s,30
3,S,30
1,X,20
2,X,20
3,X,20
3,S,20
4,F,91
4,F,90
5,,90
6,F,
7,F,
4,,10
3,S,20
1,,20
;;
RUN;

data want (drop=_:);
  set _1;
  retain status '  '         /* Either "NA" or 2 blanks                      */
         _terminate_level .  /* Level which will return status to blank      */
         _countdown .        /* 1 means the following obs starts status="NA" */;

  if _countdown=1 then do;   /* Start NA status */
    status='NA';
    _countdown=.;
  end;
  else if status=' ' and level&amp;gt;2 and blank_90 in (.,90) then do;
    _terminate_level=level;
    _countdown=1;
  end;
  else if level=_terminate_level then call missing(of _:,status);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 02 Mar 2024 21:15:50 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2024-03-02T21:15:50Z</dc:date>
    <item>
      <title>How to get observation from between the segment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918673#M361873</link>
      <description>&lt;P&gt;Conditions Leve 1 &amp;amp; Level 2 are Indicator for next segment So conditions won't Apply for these two level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whenever F_there column has "F" value and Blank_90 column has (" " / 90) value then those line need to be highlighted and if these things appear in a any level apart from I and 2 level then below need to be highlighted until Same level appear again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In below example I have 2 segments and I need green things need to be marked has NA , Because in yellow line you can see level 3 which has (F and blank) value satisfy the condition so we need lines from 3 to Next appearing 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached excel , PLease help me to sort it out .&lt;/P&gt;
&lt;P&gt;For any querry please post here&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2024 04:28:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918673#M361873</guid>
      <dc:creator>Sharath_naik</dc:creator>
      <dc:date>2024-03-02T04:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to get observation from between the segment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918676#M361876</link>
      <description>&lt;P&gt;Any code we would write would have to work on the corresponding SAS data set and not on the Excel file. Furthermore, many of us refuse to download Microsoft Office files as they can be a security threat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So please provide us with the SAS data set, by following &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;. Do not provide the data set any other way.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2024 10:48:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918676#M361876</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-03-02T10:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to get observation from between the segment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918679#M361879</link>
      <description>Here is the dataset :&lt;BR /&gt;&lt;BR /&gt;data _1;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;INPUT Level:8. F_there:$1. Blank_90:8.;&lt;BR /&gt;DATALINES ;&lt;BR /&gt;1,x,20&lt;BR /&gt;2,x,20&lt;BR /&gt;3,F,29&lt;BR /&gt;3,F,&lt;BR /&gt;4,F,&lt;BR /&gt;4,s,90&lt;BR /&gt;5,s,&lt;BR /&gt;5,s,91&lt;BR /&gt;3,F,90&lt;BR /&gt;3,s,3&lt;BR /&gt;4,s,30&lt;BR /&gt;3,S,30&lt;BR /&gt;1,X,20&lt;BR /&gt;2,X,20&lt;BR /&gt;3,X,20&lt;BR /&gt;3,S,20&lt;BR /&gt;4,F,91&lt;BR /&gt;4,F,90&lt;BR /&gt;5,,90&lt;BR /&gt;6,F,&lt;BR /&gt;7,F,&lt;BR /&gt;4,,10&lt;BR /&gt;3,S,20&lt;BR /&gt;1,,20&lt;BR /&gt;;;&lt;BR /&gt;RUN;&lt;BR /&gt;</description>
      <pubDate>Sat, 02 Mar 2024 11:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918679#M361879</guid>
      <dc:creator>Sharath_naik</dc:creator>
      <dc:date>2024-03-02T11:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get observation from between the segment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918681#M361881</link>
      <description>&lt;P&gt;Hi Sir,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have noted you instruction and in future I will not share any data via excel&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is the dataset .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _1;&lt;BR /&gt;infile datalines dsd truncover;&lt;BR /&gt;INPUT Level:8. F_there:$1. Blank_90:8.;&lt;BR /&gt;DATALINES ;&lt;BR /&gt;1,x,20&lt;BR /&gt;2,x,20&lt;BR /&gt;3,F,29&lt;BR /&gt;3,F,&lt;BR /&gt;4,F,&lt;BR /&gt;4,s,90&lt;BR /&gt;5,s,&lt;BR /&gt;5,s,91&lt;BR /&gt;3,F,90&lt;BR /&gt;3,s,3&lt;BR /&gt;4,s,30&lt;BR /&gt;3,S,30&lt;BR /&gt;1,X,20&lt;BR /&gt;2,X,20&lt;BR /&gt;3,X,20&lt;BR /&gt;3,S,20&lt;BR /&gt;4,F,91&lt;BR /&gt;4,F,90&lt;BR /&gt;5,,90&lt;BR /&gt;6,F,&lt;BR /&gt;7,F,&lt;BR /&gt;4,,10&lt;BR /&gt;3,S,20&lt;BR /&gt;1,,20&lt;BR /&gt;;;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2024 11:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918681#M361881</guid>
      <dc:creator>Sharath_naik</dc:creator>
      <dc:date>2024-03-02T11:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to get observation from between the segment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918682#M361882</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/137094"&gt;@Sharath_naik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Conditions Leve 1 &amp;amp; Level 2 are Indicator for next segment So conditions won't Apply for these two level.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Whenever F_there column has "F" value and Blank_90 column has (" " / 90) value then those line need to be highlighted and if these things appear in a any level apart from I and 2 level then below need to be highlighted until Same level appear again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In below example I have 2 segments and I need green things need to be marked has NA , Because in yellow line you can see level 3 which has (F and blank) value satisfy the condition so we need lines from 3 to Next appearing 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached excel , PLease help me to sort it out .&lt;/P&gt;
&lt;P&gt;For any querry please post here&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please also show us the desired output. A screen capture is fine, please use the "Insert Photos" icon to include your screen capture in your reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please explain what you mean by "need to be highlighted". In a SAS data set, there is no such thing as a "highlight".&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 879px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/91641i24282B42CFE94122/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2024 11:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918682#M361882</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-03-02T11:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get observation from between the segment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918685#M361885</link>
      <description>&lt;P&gt;I don't see any values for Blank_90&amp;nbsp; of " (" " / 90) " . If that is supposed to mean "Blank_90 is blank (or missing) or has a value of "90" then say so. Your original statement implies something entirely different.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2024 15:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918685#M361885</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-02T15:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get observation from between the segment</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918698#M361891</link>
      <description>&lt;P&gt;Thank you for supplying your sample data as a working DATA step.&amp;nbsp; I don't see a similar sample of the corresponding expected output, but I suspect this is what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _1;
infile datalines dsd truncover;
INPUT Level:8. F_there:$1. Blank_90:8.;
DATALINES ;
1,x,20
2,x,20
3,F,29
3,F,
4,F,
4,s,90
5,s,
5,s,91
3,F,90
3,s,3
4,s,30
3,S,30
1,X,20
2,X,20
3,X,20
3,S,20
4,F,91
4,F,90
5,,90
6,F,
7,F,
4,,10
3,S,20
1,,20
;;
RUN;

data want (drop=_:);
  set _1;
  retain status '  '         /* Either "NA" or 2 blanks                      */
         _terminate_level .  /* Level which will return status to blank      */
         _countdown .        /* 1 means the following obs starts status="NA" */;

  if _countdown=1 then do;   /* Start NA status */
    status='NA';
    _countdown=.;
  end;
  else if status=' ' and level&amp;gt;2 and blank_90 in (.,90) then do;
    _terminate_level=level;
    _countdown=1;
  end;
  else if level=_terminate_level then call missing(of _:,status);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Mar 2024 21:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-observation-from-between-the-segment/m-p/918698#M361891</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-03-02T21:15:50Z</dc:date>
    </item>
  </channel>
</rss>

