<?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: How can I get the first and the last MISSING value from a particular ROW in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/778155#M247690</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
infile datalines missover;
  input id $ var1 $ var2 $ var3 $ var4 $ var5 $ var6 $ var7 $ var8 $ var9 $ var10 $ var11 $ var12 $;
cards;
A 1 2 3 . . . . . 1 1 1 3
B 3 3 2 1 3 2 1 . . . . .
C . . . . 1 2 3 1 2 3 2 .
D 3 . 1 . 3 . 1 . 3 . 1 .
F 1 3 . . 1 3 . . 1 3 . .
E 3 2 1 . . . . . 1 1 1 3
G 3 3 2 1 3 2 1 . . . . .
H . . . . . 1 2 3 1 2 3 2
I 3 . 1 . 3 . 1 . 3 . 1 .
J A E . . A E . . A E . . 
;

data want;
 set example;
 array x{*} $ var:;
 do i = 1 to dim(x);
   if missing(x{i}) then do;
        first=vname(x{i});leave;
   end;
 end;

 do i = dim(x) to 1 by -1;
   if missing(x{i}) then do;
        last=vname(x{i});leave;
   end;
 end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 03 Nov 2021 12:01:57 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-11-03T12:01:57Z</dc:date>
    <item>
      <title>How can I get the first and the last MISSING value from a particular ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/777929#M247593</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have the following problem, I want to identify the first and the last missing values in a row. Take as an example the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
  input id var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11 var12;
cards;

A	1 2 3 . . . . . 1 1 1 3
B	3 3 2 1 3 2 1 . . . . .
C	. . . . 1 2 3 1 2 3 2 .
D	3 . 1 . 3 . 1 . 3 . 1 .
F	1 3 . . 1 3 . . 1 3 . .
E	3 2 1 . . . . . 1 1 1 3
G	3 3 2 1 3 2 1 . . . . .
H	. . . . . 1 2 3 1 2 3 2
I	3 . 1 . 3 . 1 . 3 . 1 .
J	A E . . A E . . A E . . 
;&lt;/PRE&gt;
&lt;P&gt;In row A the first is var4 and the last var8&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In row D the first is var2 and the last is var12&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Nov 2021 15:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/777929#M247593</guid>
      <dc:creator>ramgouveia</dc:creator>
      <dc:date>2021-11-02T15:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the first and the last MISSING value from a particular ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/777968#M247610</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
infile datalines missover;
  input id $ var1 $ var2 $ var3 $ var4 $ var5 $ var6 $ var7 $ var8 $ var9 $ var10 $ var11 $ var12 $;
cards;
A 1 2 3 . . . . . 1 1 1 3
B 3 3 2 1 3 2 1 . . . . .
C . . . . 1 2 3 1 2 3 2 .
D 3 . 1 . 3 . 1 . 3 . 1 .
F 1 3 . . 1 3 . . 1 3 . .
E 3 2 1 . . . . . 1 1 1 3
G 3 3 2 1 3 2 1 . . . . .
H . . . . . 1 2 3 1 2 3 2
I 3 . 1 . 3 . 1 . 3 . 1 .
J A E . . A E . . A E . . 
;

data want (drop = i);
	set example;
	length first last $5.;
	array _v [*] var:;
	first = catt("var", whichc("", of var:));
	do i = 1 to dim(_v);
		if missing(_v[i]) then last = vname(_v[i]);
	end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;id var1 var2 var3 var4 var5 var6 var7 var8 var9 var10 var11 var12 first last 
A 1 2 3           1 1 1 3 var4 var8 
B 3 3 2 1 3 2 1           var8 var12 
C         1 2 3 1 2 3 2   var1 var12 
D 3   1   3   1   3   1   var2 var12 
E 3 2 1           1 1 1 3 var4 var8 
F 1 3     1 3     1 3     var3 var12 
G 3 3 2 1 3 2 1           var8 var12 
H           1 2 3 1 2 3 2 var1 var5 
I 3   1   3   1   3   1   var2 var12 
J A E     A E     A E     var3 var12 
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;I should add that this would be much easier if you transposed the data set, but I'm not quite sure what you're actually working with as far as data size. &lt;/P&gt;</description>
      <pubDate>Tue, 02 Nov 2021 16:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/777968#M247610</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2021-11-02T16:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the first and the last MISSING value from a particular ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/777971#M247613</link>
      <description>&lt;P&gt;Some minor details:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you expect to see if there are no missing values?&lt;/P&gt;
&lt;P&gt;What do you expect to see if there is exactly one missing value? The "first" would also be the "last" in that case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are all of the variables you want to search of the same type, all numeric or all character? If not there is much more work involved. Since your row J shows values of A and E, that the data step provided will make missing this could be pretty important question. (Not to mention that the row identification letters don't make it into the data set either).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Nov 2021 17:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/777971#M247613</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-11-02T17:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the first and the last MISSING value from a particular ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/777993#M247617</link>
      <description>&lt;P&gt;What is you also had this array&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array _vr [*] var12-var1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Nov 2021 18:50:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/777993#M247617</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2021-11-02T18:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can I get the first and the last MISSING value from a particular ROW</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/778155#M247690</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data example;
infile datalines missover;
  input id $ var1 $ var2 $ var3 $ var4 $ var5 $ var6 $ var7 $ var8 $ var9 $ var10 $ var11 $ var12 $;
cards;
A 1 2 3 . . . . . 1 1 1 3
B 3 3 2 1 3 2 1 . . . . .
C . . . . 1 2 3 1 2 3 2 .
D 3 . 1 . 3 . 1 . 3 . 1 .
F 1 3 . . 1 3 . . 1 3 . .
E 3 2 1 . . . . . 1 1 1 3
G 3 3 2 1 3 2 1 . . . . .
H . . . . . 1 2 3 1 2 3 2
I 3 . 1 . 3 . 1 . 3 . 1 .
J A E . . A E . . A E . . 
;

data want;
 set example;
 array x{*} $ var:;
 do i = 1 to dim(x);
   if missing(x{i}) then do;
        first=vname(x{i});leave;
   end;
 end;

 do i = dim(x) to 1 by -1;
   if missing(x{i}) then do;
        last=vname(x{i});leave;
   end;
 end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Nov 2021 12:01:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-can-I-get-the-first-and-the-last-MISSING-value-from-a/m-p/778155#M247690</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-11-03T12:01:57Z</dc:date>
    </item>
  </channel>
</rss>

