<?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: Inter-observational checks of values for each ID in data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938778#M368696</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thank you for your suggestions. Since the desired output was requested:&lt;/P&gt;&lt;PRE&gt;ID Product Acc Type Value1-Value3 Err&lt;BR /&gt;1 C 3 Red 3 3 1
1 A 1 Blue 2 1 0 E1
1 E   . . . E2
2 D 2 Orange 0 2 . E1
2 B 4 Yellow 4 4 2 E3
3 B 3 Blue 5 3 . E1
3 C 5 Orange 1 1 .
3 E  . . . E2&lt;/PRE&gt;</description>
    <pubDate>Fri, 09 Aug 2024 09:41:10 GMT</pubDate>
    <dc:creator>nemez</dc:creator>
    <dc:date>2024-08-09T09:41:10Z</dc:date>
    <item>
      <title>Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938561#M368644</link>
      <description>&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set like the following one (which is created from three different data sets of similar structure).&lt;/P&gt;&lt;PRE&gt;data have;&lt;BR /&gt;input ID $ Product $ Acc $ Type $ Value1 Value2 Value3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 C 3 Red 3 3 1&lt;BR /&gt;1 A 1 Blue 2 1 0&lt;BR /&gt;2 D 2 Orange 0 2 .&lt;BR /&gt;2 B 4 Yellow 4 4 2&lt;BR /&gt;3 B 3 Blue 5 3 .&lt;BR /&gt;3 C 5 Orange 1 1 .&lt;BR /&gt;;&lt;/PRE&gt;&lt;P&gt;Now, I want to perform some "intra-observation" checks to detect errors and also sometimes conditionally create new rows like in this example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;by ID;&lt;BR /&gt;if Value1 ^= Value2 then Err = 'E1';&lt;BR /&gt;output;&lt;BR /&gt;if Type in ('Blue','Orange') and find(Product,'E') = 0 then do;&lt;BR /&gt;Product = 'E';&lt;BR /&gt;Acc = '';&lt;BR /&gt;Type = '';&lt;BR /&gt;Value1 = .;&lt;BR /&gt;Value2 = .;&lt;BR /&gt;Value3 = .;&lt;BR /&gt;Err = 'E2';&lt;BR /&gt;if last.ID then output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Besides, I also want to perform "inter-observation" checks for each ID, f. ex. whether for certain combinations of Product and Acc some condition is fulfilled, f. ex. (fake code):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;do over ID;&lt;BR /&gt;if for comb('B','4') Value1 &amp;gt; 0 and for comb('D','2') Value1 = 0 then do;&lt;BR /&gt;...
Err = 'E3';
if last.ID then output;
end;&lt;BR /&gt;end;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(note that I am referring to obs 4 and 3 in the "have" data set).&lt;/P&gt;&lt;P&gt;I have not been able to do this within a data step and I am starting to think that this operation might only possible with "proc iml" or some other way. However, I have no experience in working with SAS/IML and thus, any suggestions are appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2024 15:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938561#M368644</guid>
      <dc:creator>nemez</dc:creator>
      <dc:date>2024-08-07T15:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938616#M368662</link>
      <description>&lt;P&gt;Your description of your objective is very sparse.&amp;nbsp; But you can do "inter" obs comparsons by reading through a single id group, in a DO UNTIL LAST.ID&amp;nbsp; do-group.&amp;nbsp; Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ Product $ Acc $ Type $ Value1 Value2 Value3;
datalines;
1 C 3 Red 3 3 1
1 A 1 Blue 2 1 0
2 D 2 Orange 0 2 .
2 B 4 Yellow 4 4 2
3 B 3 Blue 5 3 .
3 C 5 Orange 1 1 .
;

data want (keep=ID ERR);
  do until (last.id);
    set have;
    by id;
    if catx(',',product,acc)='B,4' and value1&amp;gt;0 then _condition_a1=1; else 
    if catx(',',product,acc)='D,2' and value1=0 then _condition_a2=1; 

    length type_list $400;
    type_list=catx(',',type_list,type);

  end;
  length ERR $10;
  if n(of _condition_a:)=2 then do;
    err='E3';
    output;
  end;

  if findw(type_list,'Blue')&amp;gt;0 and findw(type_list,'Orange')&amp;gt;0 then do;
    err='Type 2 error';
    output;
  end;
run;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Aug 2024 02:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938616#M368662</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2024-08-08T02:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938617#M368663</link>
      <description>&lt;P&gt;You could try PROC SQL.&lt;/P&gt;
&lt;P&gt;And better to post your desired output to better explain your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ Product $ Acc $ Type $ Value1 Value2 Value3;
datalines;
1 C 3 Red 3 3 1
1 A 1 Blue 2 1 0
2 D 2 Orange 0 2 .
2 B 4 Yellow 4 4 2
3 B 3 Blue 5 3 .
3 C 5 Orange 1 1 .
;

proc sql;
select id, 

case
when sum(type in ('Blue','Orange')) and sum(Product='E')  then 'E'
else ' '
end as Product

 from have
  group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Aug 2024 02:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938617#M368663</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-08T02:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938639#M368667</link>
      <description>&lt;P&gt;Another way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE(index=(A=(ID PRODUCT ACC)));
  input ID $ PRODUCT $ ACC $ TYPE $ VALUE1 VALUE2 VALUE3;
datalines;
1 C 3 Red 3 3 1
1 A 1 Blue 2 1 0
2 D 2 Orange 0 2 .
2 B 4 Yellow 4 4 2
3 B 3 Blue 5 3 .
3 C 5 Orange 1 1 .
run;

data WANT;
  set HAVE;
  by ID;
  if last.ID then do;
     * save values of PRODUCT and ACC here if needed ;
 
    * if for comb('B','4') VALUE1 &amp;gt; 0  ;
    PRODUCT='B'; ACC='4'; 
    set HAVE key=A;
    _CONDITION1= (^_IORC_ &amp;amp; VALUE1 &amp;gt; 0); * keys found and value &amp;gt; 0 ; 
    
    * and for comb('D','2') VALUE1 = 0 ;
    PRODUCT='D'; ACC='2'; 
    set HAVE key=A;
    _CONDITION2= (^_IORC_ &amp;amp; VALUE1 = 0); * keys found and value = 0 ; 
    
    if _CONDITION1 &amp;amp; _CONDITION2 then FLAG='Y';
    * restore values of PRODUCT and ACC here if needed ;
    
    output;
    _IORC_=0; _ERROR_=0;
    putlog ID= FLAG=;
  end;
  drop _:;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="sasSource"&gt;ID=1 FLAG=&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;ID=2 FLAG=Y&lt;/DIV&gt;
&lt;DIV class="sasSource"&gt;ID=3 FLAG=&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;PRE id="pre_sasLog_126663" class="sasLog" style="background-color: transparent; -webkit-user-select: text; -webkit-user-modify: read-only; -webkit-touch-callout: default; border-top-width: 0px; border-bottom-width: 0px;"&gt;&amp;nbsp;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Aug 2024 08:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938639#M368667</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-08-08T08:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938775#M368694</link>
      <description>&lt;P&gt;Hello ChrisNZ,&lt;/P&gt;&lt;P&gt;thank you, your approach looks very promising. How would I have to change your piece of code to put the flag in the obs where condition 2 is checked (here obs=3, but in the real data set it would not have to be the row where first.ID = 1)?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 09:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938775#M368694</guid>
      <dc:creator>nemez</dc:creator>
      <dc:date>2024-08-09T09:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938778#M368696</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Thank you for your suggestions. Since the desired output was requested:&lt;/P&gt;&lt;PRE&gt;ID Product Acc Type Value1-Value3 Err&lt;BR /&gt;1 C 3 Red 3 3 1
1 A 1 Blue 2 1 0 E1
1 E   . . . E2
2 D 2 Orange 0 2 . E1
2 B 4 Yellow 4 4 2 E3
3 B 3 Blue 5 3 . E1
3 C 5 Orange 1 1 .
3 E  . . . E2&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Aug 2024 09:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938778#M368696</guid>
      <dc:creator>nemez</dc:creator>
      <dc:date>2024-08-09T09:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938783#M368698</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;data out;
input ID $ Product $ Acc $ Type $ Value1 Value2 Value3 Err $;
datalines;
1 C 3 Red 3 3 1 .
1 A 1 Blue 2 1 0 E1
1 E . . . . . E2
2 D 2 Orange 0 2 . E1
2 B 4 Yellow 4 4 2 E3
3 B 3 Blue 5 3 . E1
3 C 5 Orange 1 1 . .
3 E . . . . . E2
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;To be precise.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 09:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938783#M368698</guid>
      <dc:creator>nemez</dc:creator>
      <dc:date>2024-08-09T09:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938863#M368727</link>
      <description>&lt;P&gt;The logic you want is still a bit unclear. This matches your output. Please adapt as needed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WANT;
  set HAVE point=_N_;
  by ID;
  if VALUE1 ^= VALUE2 then ERR = 'E1';
  output;
  if TYPE in ('Blue','Orange') &amp;amp; ^find(PRODUCT,'E') then do;
    call missing(ACC, TYPE, VALUE1, VALUE2, VALUE3);
    PRODUCT = 'E';
    ERR = 'E2';
    if last.ID then output;
  end;
  if PRODUCT='D' &amp;amp; ACC='2' then do;
    _PRODUCT=PRODUCT; _ACC=ACC;
    PRODUCT='B'; ACC='4'; 
    set HAVE key=A;
    if ^_IORC_ &amp;amp; VALUE1 &amp;gt; 0 then do; 
      ERR = 'E3';
      PRODUCT=_PRODUCT; ACC=_ACC;
      output;
      _IORC_=0; _ERROR_=0;
    end; 
  end;
  drop _:;
run;
proc print;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE class="table" style="border-spacing: 0;" aria-label="Data Set WORK.OUT"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;ID&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;Product&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;Acc&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;Type&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Value1&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Value2&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;Value3&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;Err&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="data"&gt;1&lt;/TD&gt;
&lt;TD class="data"&gt;C&lt;/TD&gt;
&lt;TD class="data"&gt;3&lt;/TD&gt;
&lt;TD class="data"&gt;Red&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;2&lt;/TH&gt;
&lt;TD class="data"&gt;1&lt;/TD&gt;
&lt;TD class="data"&gt;A&lt;/TD&gt;
&lt;TD class="data"&gt;1&lt;/TD&gt;
&lt;TD class="data"&gt;Blue&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="data"&gt;E1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;3&lt;/TH&gt;
&lt;TD class="data"&gt;1&lt;/TD&gt;
&lt;TD class="data"&gt;E&lt;/TD&gt;
&lt;TD class="data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="data"&gt;E2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;4&lt;/TH&gt;
&lt;TD class="data"&gt;2&lt;/TD&gt;
&lt;TD class="data"&gt;D&lt;/TD&gt;
&lt;TD class="data"&gt;2&lt;/TD&gt;
&lt;TD class="data"&gt;Orange&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="data"&gt;E1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;5&lt;/TH&gt;
&lt;TD class="data"&gt;2&lt;/TD&gt;
&lt;TD class="data"&gt;B&lt;/TD&gt;
&lt;TD class="data"&gt;4&lt;/TD&gt;
&lt;TD class="data"&gt;Yellow&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;4&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="data"&gt;E3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;6&lt;/TH&gt;
&lt;TD class="data"&gt;3&lt;/TD&gt;
&lt;TD class="data"&gt;B&lt;/TD&gt;
&lt;TD class="data"&gt;3&lt;/TD&gt;
&lt;TD class="data"&gt;Blue&lt;/TD&gt;
&lt;TD class="r data"&gt;5&lt;/TD&gt;
&lt;TD class="r data"&gt;3&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="data"&gt;E1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;7&lt;/TH&gt;
&lt;TD class="data"&gt;3&lt;/TD&gt;
&lt;TD class="data"&gt;C&lt;/TD&gt;
&lt;TD class="data"&gt;5&lt;/TD&gt;
&lt;TD class="data"&gt;Orange&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;8&lt;/TH&gt;
&lt;TD class="data"&gt;3&lt;/TD&gt;
&lt;TD class="data"&gt;E&lt;/TD&gt;
&lt;TD class="data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="data"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="r data"&gt;.&lt;/TD&gt;
&lt;TD class="data"&gt;E2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Aug 2024 06:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938863#M368727</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2024-08-10T06:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938864#M368728</link>
      <description>&lt;P&gt;Assuming I understood what you mean.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input ID $ Product $ Acc $ Type $ Value1 Value2 Value3;
datalines;
1 C 3 Red 3 3 1
1 A 1 Blue 2 1 0
2 D 2 Orange 0 2 .
2 B 4 Yellow 4 4 2
3 B 3 Blue 5 3 .
3 C 5 Orange 1 1 .
;

data want;
do until(last.id);
 set have;
 by id;
 Err='  ';
 if Value1 ^= Value2 then Err = 'E1';

 if Product='B' and Acc='4' and value1&amp;gt;0 then flag31=1;
 if Product='D' and Acc='2' and value1=0 then flag32=1;
 if last.id and  flag31=1 and flag32=1 then Err='E3';
 output;

 if last.id and  Type in ('Blue','Orange') and find(Product,'E') = 0 then do;
   Product='E';call missing(of Acc--Value3);Err='E2';output;
 end;
end; 
drop  flag31 flag32;
run;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Aug 2024 07:04:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938864#M368728</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-08-10T07:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938949#M368749</link>
      <description>&lt;P&gt;Hello ChrisNZ,&lt;/P&gt;&lt;P&gt;Unfortunately, the point-option does not work for me.&lt;/P&gt;&lt;P&gt;I got an error message, stating:&lt;/P&gt;&lt;DIV class=""&gt;ERROR: The POINT= option is incompatible with the BY statement.&lt;/DIV&gt;</description>
      <pubDate>Mon, 12 Aug 2024 12:36:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938949#M368749</guid>
      <dc:creator>nemez</dc:creator>
      <dc:date>2024-08-12T12:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938950#M368750</link>
      <description>&lt;P&gt;Hello Ksharp,&lt;/P&gt;&lt;P&gt;thank you for helpful suggestion! However, I need to have more flexibility in the code (regarding the "if last.ID ..." parts) and have found a solution that works fine for me with two do-until-loops, see below.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data want(drop=flag:);
do until (last.ID);
set have;
by ID;
if find(Product,'E') = 0 then flag2 = 1;
if Product = 'B' and Acc = '4' and Value1 &amp;gt; 0 then flag31 = 1;
if Product = 'D' and Acc = '2' and Value1 = 0 then flag32 = 1;
end;
do until (last.ID);
set out;
by ID;
output;
if Value1 ^= Value2 then Err = 'E1';
if Type in ('Blue','Orange') and flag2 = 1  then do;
	Product='E'; call missing(of Acc--Value3); Err='E2';
end;
if flag31 = 1 and flag32 = 1 then Err = 'E3';
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/216503"&gt;@all&lt;/a&gt;: Thanks for your suggestions/help!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 12:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938950#M368750</guid>
      <dc:creator>nemez</dc:creator>
      <dc:date>2024-08-12T12:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Inter-observational checks of values for each ID in data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938954#M368751</link>
      <description>&lt;P&gt;Just for the record: If using Ksharps code without the "last.ID"-condition regarding Err 'E3' it works fine.&lt;/P&gt;&lt;P&gt;I myself have discovered that the double do-until-loop (where I had a little mistake as I read in "out" instead of "have" in the second do-until-loop and therefore had to adjust some more lines) for some reason does not correctly detect Error 'E1' in one instance.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 13:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inter-observational-checks-of-values-for-each-ID-in-data-set/m-p/938954#M368751</guid>
      <dc:creator>nemez</dc:creator>
      <dc:date>2024-08-12T13:11:13Z</dc:date>
    </item>
  </channel>
</rss>

