<?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: Flag observations with one specific value only in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Flag-observations-with-one-specific-value-only/m-p/563110#M17276</link>
    <description>&lt;P&gt;Something like below should do the job.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input ID Time1 $ 6-13 Time2 $14-22 Time3 $23-31;
  datalines;
1234 Current          Current
5678 Current Current3 Current
3456 Corrent Past     Current
9876
2345 Current 
;

data want1(drop=_:);
  set have;
  array x{*} $ time1-time3;

  flag=0;
  do _i=1 to dim(x);
    if not missing(x[_i]) then
      do;
        if missing(_xi) then 
          do;
            _xi=_i;
            flag=1;
          end;
        else 
        if x[_xi] ne x[_i] then
          do;
            flag=0;
            leave;
          end;
      end;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 02 Jun 2019 01:18:45 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2019-06-02T01:18:45Z</dc:date>
    <item>
      <title>Flag observations with one specific value only</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Flag-observations-with-one-specific-value-only/m-p/563108#M17275</link>
      <description>&lt;P&gt;I am trying to flag the observations that contain the same value anywhere along the row. I can return all the observations that have one specific value somewhere along the row, but not what I am looking for. Can someone help please.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want as output is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;Time1&amp;nbsp; &amp;nbsp;Time1&amp;nbsp; &amp;nbsp; Time1&amp;nbsp; &amp;nbsp; &amp;nbsp; Flag&lt;/P&gt;
&lt;P&gt;1234 Current Current&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;5678 Current Current3 Current&amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;3456 Corrent Past Current&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;BR /&gt;2345 Current&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA have;
INPUT ID Time1 $ 6-13 Time2 $14-22 Time3 $23-31;
CARDS; 
1234 Current 		  Current
5678 Current Current3 Current
3456 Corrent Past  	  Current
2345 Current 
;
RUN;

DATA want1;
SET have;
ARRAY x{*} time1-time3;
flag='Current' in x;
RUN;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jun 2019 21:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Flag-observations-with-one-specific-value-only/m-p/563108#M17275</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2019-06-01T21:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Flag observations with one specific value only</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Flag-observations-with-one-specific-value-only/m-p/563110#M17276</link>
      <description>&lt;P&gt;Something like below should do the job.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input ID Time1 $ 6-13 Time2 $14-22 Time3 $23-31;
  datalines;
1234 Current          Current
5678 Current Current3 Current
3456 Corrent Past     Current
9876
2345 Current 
;

data want1(drop=_:);
  set have;
  array x{*} $ time1-time3;

  flag=0;
  do _i=1 to dim(x);
    if not missing(x[_i]) then
      do;
        if missing(_xi) then 
          do;
            _xi=_i;
            flag=1;
          end;
        else 
        if x[_xi] ne x[_i] then
          do;
            flag=0;
            leave;
          end;
      end;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Jun 2019 01:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Flag-observations-with-one-specific-value-only/m-p/563110#M17276</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-06-02T01:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Flag observations with one specific value only</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Flag-observations-with-one-specific-value-only/m-p/563127#M17279</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA have;
INPUT ID Time1 $ 6-13 Time2 $14-22 Time3 $23-31;
CARDS; 
1234 Current 		  Current
5678 Current Current3 Current
3456 Corrent Past  	  Current
2345 Current 
;
RUN;

DATA want1;
if _n_=1 then do;
 length k $ 100;
 declare hash h();
 h.definekey('k');
 h.definedone();
end;
SET have;
ARRAY x{*} $ time1-time3;
do i=1 to dim(x);
 if not missing(x{i}) then do;k=x{i};h.ref();end;
end;
flag=(h.num_items=1);
h.clear();
drop i k;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 Jun 2019 11:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Flag-observations-with-one-specific-value-only/m-p/563127#M17279</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-06-02T11:35:50Z</dc:date>
    </item>
  </channel>
</rss>

