<?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: 'Below' in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639736#M190382</link>
    <description>&lt;P&gt;In case I forgot to mention: A WORKING data step that creates a dataset, and not just a log full of ERRORs.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Apr 2020 13:03:13 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-04-14T13:03:13Z</dc:date>
    <item>
      <title>'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639717#M190370</link>
      <description>&lt;P&gt;How would I be able to say something like "if row2 BELOW row1 then flag=0"&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 12:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639717#M190370</guid>
      <dc:creator>mar0000</dc:creator>
      <dc:date>2020-04-14T12:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: 'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639718#M190371</link>
      <description>&lt;P&gt;What does "below" mean? Does it mean less than?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are row1 and row2 names of variables, or are they actually referring to different rows?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 12:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639718#M190371</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-14T12:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: 'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639721#M190373</link>
      <description>Row 1 and 2 are actually different rows. My variable name is 'Type' and if Type = '2' then flag=1. I want to say if Type = '5' and is below Type = '2' that has flag = 1 then flag = 0. If Type = '5' and is below Type = '2' when flag is 0 then the flag should be 1. I want to base Type '5' off of Type '2.' Whatever Type 2 has flagged, I want type 5 to do the opposite</description>
      <pubDate>Tue, 14 Apr 2020 12:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639721#M190373</guid>
      <dc:creator>mar0000</dc:creator>
      <dc:date>2020-04-14T12:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: 'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639725#M190375</link>
      <description>This may make more sense: if Type 2 is flagged 1, I want Type 5 to flag 0. If Type 2 is flagged 0, I want Type 5 to flag 1.</description>
      <pubDate>Tue, 14 Apr 2020 12:45:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639725#M190375</guid>
      <dc:creator>mar0000</dc:creator>
      <dc:date>2020-04-14T12:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: 'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639727#M190376</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT size="7"&gt;PLEASE&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="4"&gt;supply example data in usable form (data step(s) with datalines), so&lt;/FONT&gt;&lt;FONT size="4"&gt;&amp;nbsp;we all don't waste time guessing what you have and what you want.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 12:50:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639727#M190376</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-14T12:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: 'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639730#M190378</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/322090"&gt;@mar0000&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;This may make more sense: if Type 2 is flagged 1, I want Type 5 to flag 0. If Type 2 is flagged 0, I want Type 5 to flag 1.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So what does this have to do with rows? Can you please show us an example data set, and then show us the desired output?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 12:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639730#M190378</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-14T12:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: 'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639731#M190379</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
Type;
1
2&lt;BR /&gt;5
3
4
5&lt;BR /&gt;
;

data want;
set have;
if type = '2' then flag = 1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to say: if type = 2 and flag = 1 then when type = 5, the flag should be 0. If type = 5 is by itself (such as the last line of data), then the flag should be 1.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 12:57:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639731#M190379</guid>
      <dc:creator>mar0000</dc:creator>
      <dc:date>2020-04-14T12:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: 'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639733#M190381</link>
      <description>&lt;P&gt;Desired output&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Type Flag&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 12:58:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639733#M190381</guid>
      <dc:creator>mar0000</dc:creator>
      <dc:date>2020-04-14T12:58:43Z</dc:date>
    </item>
    <item>
      <title>Re: 'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639736#M190382</link>
      <description>&lt;P&gt;In case I forgot to mention: A WORKING data step that creates a dataset, and not just a log full of ERRORs.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 13:03:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639736#M190382</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-14T13:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: 'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639738#M190383</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/322090"&gt;@mar0000&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the following code meet your expectations?&lt;/P&gt;
&lt;P&gt;The LAG() function retrieves the value from the previous row.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	flag = 1;
	_lag = lag(Type);
	if (Type=2 and _lag=5) or (Type=5 and _lag=2) then flag=0;
	drop _lag;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 13:07:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639738#M190383</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-04-14T13:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: 'Below'</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639740#M190384</link>
      <description>&lt;P&gt;So you seem to mean:&lt;/P&gt;
&lt;P&gt;when a type of 5 immediately follows a type of 2, flag should be 0, otherwise it should be zero?&lt;/P&gt;
&lt;P&gt;If that is the case:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
flag = not (type = 5 and lag(type) = 2);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Apr 2020 13:08:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Below/m-p/639740#M190384</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-14T13:08:01Z</dc:date>
    </item>
  </channel>
</rss>

