<?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 array question: in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/array-question/m-p/68370#M19581</link>
    <description>Hi Folks,&lt;BR /&gt;
I have an excel with 5 columns( ID, Visit, Time, Data2, Marker). Marker has a "Mark" tag depending on the analysis. My requirement here is to keep 3 records from the third row once I see  "Mark" tag in the marker variable. I used this code &lt;BR /&gt;
&lt;BR /&gt;
Data a;set b;&lt;BR /&gt;
retain marker_flg marker_cnt;&lt;BR /&gt;
 marker_flg=0;marker_cnt=0;&lt;BR /&gt;
 if marker_flg=0 and index(upcase(marker),'MARK') then do;&lt;BR /&gt;
            marker_cnt=1;&lt;BR /&gt;
            marker_flg=1;&lt;BR /&gt;
      end;&lt;BR /&gt;
else if marker_flg=1 &amp;amp; index(upcase(marker),'MARK')=0 then do;&lt;BR /&gt;
            marker_cnt=marker_cnt+1;&lt;BR /&gt;
		  if marker_cnt&amp;gt;=3 and marker_cnt&amp;lt;6 then do;&lt;BR /&gt;
                  length test_type $ 20;&lt;BR /&gt;
                  test_type='2.5min';&lt;BR /&gt;
                  output;&lt;BR /&gt;
            end;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
When I use this code I was able to successfully pull the desired 3 rows. But in few excel files I have a mark flag in the marker variable in between. here is an example&lt;BR /&gt;
&lt;BR /&gt;
ID    VI    Time   Data1   Marker&lt;BR /&gt;
1      1    10:30   11.2       &lt;BR /&gt;
1      1    11:00    12       Mark&lt;BR /&gt;
1      1    11:30    11       &lt;BR /&gt;
1      1    12:00    10&lt;BR /&gt;
1      1    12:30    11&lt;BR /&gt;
1      1     01:00   12       *Mark*&lt;BR /&gt;
1      1    01:30    11&lt;BR /&gt;
1      1    02:00    10&lt;BR /&gt;
&lt;BR /&gt;
In this example if I use the above code I can successfully keep records with times 12:00,12:30 and 01:00. My question is what should I do if I have an other MARK tag at 01:00 in the marker variable and I want to just keep two rows ( 12:00 and 12:30)?  As I read multiple excel files from a folder I don't know which once have a MARK tag in between. &lt;BR /&gt;
&lt;BR /&gt;
Any help is greatly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Matt&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;&lt;/I&gt;&lt;U&gt;&lt;/U&gt;</description>
    <pubDate>Mon, 15 Mar 2010 18:09:06 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-03-15T18:09:06Z</dc:date>
    <item>
      <title>array question:</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/array-question/m-p/68370#M19581</link>
      <description>Hi Folks,&lt;BR /&gt;
I have an excel with 5 columns( ID, Visit, Time, Data2, Marker). Marker has a "Mark" tag depending on the analysis. My requirement here is to keep 3 records from the third row once I see  "Mark" tag in the marker variable. I used this code &lt;BR /&gt;
&lt;BR /&gt;
Data a;set b;&lt;BR /&gt;
retain marker_flg marker_cnt;&lt;BR /&gt;
 marker_flg=0;marker_cnt=0;&lt;BR /&gt;
 if marker_flg=0 and index(upcase(marker),'MARK') then do;&lt;BR /&gt;
            marker_cnt=1;&lt;BR /&gt;
            marker_flg=1;&lt;BR /&gt;
      end;&lt;BR /&gt;
else if marker_flg=1 &amp;amp; index(upcase(marker),'MARK')=0 then do;&lt;BR /&gt;
            marker_cnt=marker_cnt+1;&lt;BR /&gt;
		  if marker_cnt&amp;gt;=3 and marker_cnt&amp;lt;6 then do;&lt;BR /&gt;
                  length test_type $ 20;&lt;BR /&gt;
                  test_type='2.5min';&lt;BR /&gt;
                  output;&lt;BR /&gt;
            end;&lt;BR /&gt;
Run;&lt;BR /&gt;
&lt;BR /&gt;
When I use this code I was able to successfully pull the desired 3 rows. But in few excel files I have a mark flag in the marker variable in between. here is an example&lt;BR /&gt;
&lt;BR /&gt;
ID    VI    Time   Data1   Marker&lt;BR /&gt;
1      1    10:30   11.2       &lt;BR /&gt;
1      1    11:00    12       Mark&lt;BR /&gt;
1      1    11:30    11       &lt;BR /&gt;
1      1    12:00    10&lt;BR /&gt;
1      1    12:30    11&lt;BR /&gt;
1      1     01:00   12       *Mark*&lt;BR /&gt;
1      1    01:30    11&lt;BR /&gt;
1      1    02:00    10&lt;BR /&gt;
&lt;BR /&gt;
In this example if I use the above code I can successfully keep records with times 12:00,12:30 and 01:00. My question is what should I do if I have an other MARK tag at 01:00 in the marker variable and I want to just keep two rows ( 12:00 and 12:30)?  As I read multiple excel files from a folder I don't know which once have a MARK tag in between. &lt;BR /&gt;
&lt;BR /&gt;
Any help is greatly appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Matt&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;&lt;/I&gt;&lt;U&gt;&lt;/U&gt;</description>
      <pubDate>Mon, 15 Mar 2010 18:09:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/array-question/m-p/68370#M19581</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-03-15T18:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: array question:</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/array-question/m-p/68371#M19582</link>
      <description>Hi Matt&lt;BR /&gt;
&lt;BR /&gt;
Not sure if this handels the cases the way you need it - but it might give you an idea how to approach the problem:&lt;BR /&gt;
&lt;BR /&gt;
data have;&lt;BR /&gt;
infile datalines truncover;&lt;BR /&gt;
input ID VI Time time5. Data1 Marker $;&lt;BR /&gt;
format time time5.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 1 10:30 11.2 &lt;BR /&gt;
1 1 11:00 12 Mark&lt;BR /&gt;
1 1 11:30 11 mark&lt;BR /&gt;
1 1 12:00 10 mark&lt;BR /&gt;
1 1 12:30 11 &lt;BR /&gt;
1 1 01:00 12 *Mark*&lt;BR /&gt;
1 1 01:30 11&lt;BR /&gt;
1 1 02:00 10&lt;BR /&gt;
1 1 02:30 10 mark&lt;BR /&gt;
1 1 03:00 10&lt;BR /&gt;
1 1 03:30 10 &lt;BR /&gt;
1 1 04:00 10&lt;BR /&gt;
1 1 04:30 10&lt;BR /&gt;
1 1 05:00 10 mark&lt;BR /&gt;
1 1 05:30 10&lt;BR /&gt;
1 1 06:00 10&lt;BR /&gt;
1 1 06:30 10&lt;BR /&gt;
1 1 07:00 10&lt;BR /&gt;
1 1 07:30 10&lt;BR /&gt;
1 1 08:00 10&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want;&lt;BR /&gt;
  set have;&lt;BR /&gt;
  by ID VI;&lt;BR /&gt;
  retain flag counter;&lt;BR /&gt;
  if first.id or counter&amp;gt;=5 then &lt;BR /&gt;
  do;&lt;BR /&gt;
    flag=0;&lt;BR /&gt;
    counter=0;&lt;BR /&gt;
  end;&lt;BR /&gt;
&lt;BR /&gt;
  flag=   ( sum(find(Marker,'mark','i')&amp;gt;0,flag)=1 );&lt;BR /&gt;
&lt;BR /&gt;
  if ( find(Marker,'mark','i') and counter&amp;lt;3 ) then&lt;BR /&gt;
  do;&lt;BR /&gt;
    flag=1;&lt;BR /&gt;
    counter=0;&lt;BR /&gt;
  end;&lt;BR /&gt;
&lt;BR /&gt;
  counter=sum(counter,1)*flag;&lt;BR /&gt;
&lt;BR /&gt;
  if counter GE 3 and counter LE 5 then output;&lt;BR /&gt;
&lt;BR /&gt;
  put flag= counter= marker=;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=want;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick</description>
      <pubDate>Tue, 16 Mar 2010 02:17:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/array-question/m-p/68371#M19582</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-03-16T02:17:51Z</dc:date>
    </item>
  </channel>
</rss>

