<?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: Flagging records with specific values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944182#M369995</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;To make this work with my environment and SAS version I also needed to explicitly define the length of the array elements.&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  array x{10} $&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt; _temporary_ ('S00' 'S10' 'S20' 'S30' 'S40' 'S50' 'S60' 'S70' 'S80' 'S90');
  array v{*} $ Var:;
  out_flg=1;
  do i=1 to dim(v);
    if not missing(v{i}) and v{i} not in&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;:&lt;/FONT&gt;&lt;/STRONG&gt; x then
      do;
        out_flg=0;
        leave;
      end;
  end;

  if out_flg then output;
  drop out_flg i;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Sep 2024 01:40:59 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2024-09-17T01:40:59Z</dc:date>
    <item>
      <title>Flagging records with specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944169#M369990</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set with multiple string variables, I would like to flag records with specific values AND exclude others. The values I want&amp;nbsp; include&amp;nbsp; S00-S10-S20-S30-S40-S50-S60-S70-S80-S90 only (example below). Is there a way to do that using arrays or something else? Thank you so much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Example of records wanted are in &lt;FONT color="#FF0000"&gt;Red&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="659"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;Obs&lt;/TD&gt;
&lt;TD width="85"&gt;Var1&lt;/TD&gt;
&lt;TD width="85"&gt;Var2&lt;/TD&gt;
&lt;TD width="85"&gt;Var3&lt;/TD&gt;
&lt;TD width="85"&gt;Var4&lt;/TD&gt;
&lt;TD width="85"&gt;Var5&lt;/TD&gt;
&lt;TD width="85"&gt;Var6&lt;/TD&gt;
&lt;TD width="85"&gt;Var7&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;S05&lt;/TD&gt;
&lt;TD&gt;S05&lt;/TD&gt;
&lt;TD&gt;S00&lt;/TD&gt;
&lt;TD&gt;S01&lt;/TD&gt;
&lt;TD&gt;S00&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;3&lt;/TD&gt;
&lt;TD&gt;&lt;FONT color="#FF0000"&gt;S20&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&lt;FONT color="#FF0000"&gt;S10&lt;/FONT&gt;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;4&l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bsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;25&lt;/TD&gt;
&lt;TD&gt;S42&lt;/TD&gt;
&lt;TD&gt;S62&lt;/TD&gt;
&lt;TD&gt;S42&lt;/TD&gt;
&lt;TD&gt;S60&lt;/TD&gt;
&lt;TD&gt;S80&lt;/TD&gt;
&lt;TD&gt;S50&lt;/TD&gt;
&lt;TD&gt;S50&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Mon, 16 Sep 2024 23:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944169#M369990</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-09-16T23:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging records with specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944172#M369991</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards truncover expandtabs;
input Obs	(Var1	Var2	Var3	Var4	Var5	Var6	Var7) ($);
cards;
2	S05	S05	S00	S01	S00	 	 
3	S20	S10	 	 	 	 	 
4	S29	S60	S60	 	 	 	 
6	S20	S61	 	 	 	 	 
7	S16	S60	S01	S01	S01	S01	S06
10	S01	S50	S50	S00	 	 	 
12	S36	S32	S40	S40	 	 	 
13	S70	 	 	 	 	 	 
14	S42	S42	S70	S80	S80	S80	S70
19	S42	S53	S40	 	 	 	 
20	S06	S00	S60	S70	 	 	 
21	S00	S40	S70	 	 	 	 
22	S42	S40	S70	 	 	 	 
23	S02	S02	S00	S40	S40	S40	S40
24	S32	S70	S01	 	 	 	 
25	S42	S62	S42	S60	S80	S50	S50
;

data want;
set have;
array x{10} $ _temporary_ ('S00' 'S10' 'S20' 'S30' 'S40' 'S50' 'S60' 'S70' 'S80' 'S90');
array v{*} $ Var:;
output=1;
do i=1 to dim(v);
 if not missing(v{i}) and v{i} not in x then do;output=0;leave;end;
end;
if output then output;
drop output i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Sep 2024 00:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944172#M369991</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-09-17T00:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging records with specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944178#M369992</link>
      <description>&lt;P&gt;Thank you! Is there a way to make _temporary_&amp;nbsp; start with the 3 character value rather than equaling it? I selected only 3 characters in my example for simplicity, what I actually have in my data are values with variable numbers of characters. I want the ones that start with the 3 I mention in my example list.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 01:25:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944178#M369992</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-09-17T01:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging records with specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944181#M369994</link>
      <description>&lt;P&gt;OK. You can change IN operator into IN:&amp;nbsp; (with colon operator).&lt;/P&gt;
&lt;PRE&gt;data want;
set have;
array x{10} $ _temporary_ ('S00' 'S10' 'S20' 'S30' 'S40' 'S50' 'S60' 'S70' 'S80' 'S90');
array v{*} $ Var:;
output=1;
do i=1 to dim(v);
 if not missing(v{i}) and v{i} not &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;in:&lt;/STRONG&gt;&lt;/FONT&gt; x then do;output=0;leave;end;
end;
if output then output;
drop output i;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Sep 2024 01:31:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944181#M369994</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-09-17T01:31:06Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging records with specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944182#M369995</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;To make this work with my environment and SAS version I also needed to explicitly define the length of the array elements.&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  array x{10} $&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt; _temporary_ ('S00' 'S10' 'S20' 'S30' 'S40' 'S50' 'S60' 'S70' 'S80' 'S90');
  array v{*} $ Var:;
  out_flg=1;
  do i=1 to dim(v);
    if not missing(v{i}) and v{i} not in&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;:&lt;/FONT&gt;&lt;/STRONG&gt; x then
      do;
        out_flg=0;
        leave;
      end;
  end;

  if out_flg then output;
  drop out_flg i;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 01:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944182#M369995</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-09-17T01:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging records with specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944183#M369996</link>
      <description>&lt;P&gt;I'm sorry, it seems that I'm doing something wrong! Data want keeps having 0 observations!! To help clarify, the string variables in my set are named "ICD_10_dx_1 to ICD_10_dx_50".&lt;/P&gt;
&lt;P&gt;This is the code I used based on yours:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;array x[10] $ _temporary_ ('S00' 'S10' 'S20' 'S30' 'S40' 'S50' 'S60' 'S70' 'S80' 'S90');&lt;BR /&gt;array v[*] ICD_10_dx_1-ICD_10_dx_50;&lt;BR /&gt;output=1;&lt;BR /&gt;do i=1 to dim(v);&lt;/P&gt;
&lt;PRE&gt;if not missing(v{i}) and v{i} not &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;in:&lt;/STRONG&gt;&lt;/FONT&gt; x then do;output=0;leave;end;
end;
if output then output;
drop output i;
run;&lt;/PRE&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;array x{10} $ _temporary_ ('S00' 'S10' 'S20' 'S30' 'S40' 'S50' 'S60' 'S70' 'S80' 'S90');&lt;BR /&gt;array v{*} $ ICD_10_dx_:;&lt;BR /&gt;output=1;&lt;BR /&gt;do i=1 to dim(v);&lt;BR /&gt;if not missing(v{i}) and v{i} not in: x then do;output=0;leave;end;&lt;BR /&gt;end;&lt;BR /&gt;if output then output;&lt;BR /&gt;drop output i;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;Where am I going wrong?!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 01:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944183#M369996</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-09-17T01:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging records with specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944186#M369997</link>
      <description>&lt;P&gt;Try if adding an explicit length for the temporary array elements will resolve this issue. That's what I had to do in my environment.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1726537864705.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/100402i8D488F442E9D28C5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1726537864705.png" alt="Patrick_0-1726537864705.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 01:51:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944186#M369997</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-09-17T01:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Flagging records with specific values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944187#M369998</link>
      <description>It worked after specifying the length!! Thank you Again for your time and brilliance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 17 Sep 2024 01:51:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Flagging-records-with-specific-values/m-p/944187#M369998</guid>
      <dc:creator>Ihsan-Mahdi</dc:creator>
      <dc:date>2024-09-17T01:51:39Z</dc:date>
    </item>
  </channel>
</rss>

