<?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: move one row up for all variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624695#M20158</link>
    <description>&lt;P&gt;I will try your code tomorrow. Thank you very much! The diagonal missing data was from a Jackknife procedure for Deming regression analysis. We don't care the ID match up or not, we need to do a matrix calculations after, which not allow missing values in there. That's why I need help to remove only the missing values. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 13 Feb 2020 23:27:15 GMT</pubDate>
    <dc:creator>sarahfung532</dc:creator>
    <dc:date>2020-02-13T23:27:15Z</dc:date>
    <item>
      <title>move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624666#M20149</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a big data with hundreds variables, each variable has a missing value that across all the variables diagonally. The data looks like:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;X1&amp;nbsp; &amp;nbsp; X2&amp;nbsp; &amp;nbsp; &amp;nbsp;X3&amp;nbsp; &amp;nbsp; X4&amp;nbsp; &amp;nbsp; X5 ...... Xn&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2.1&amp;nbsp; &amp;nbsp; 3.1&amp;nbsp; &amp;nbsp; 4.1&amp;nbsp; &amp;nbsp; 5.1&amp;nbsp; .....&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp;1.2&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3.3&amp;nbsp; &amp;nbsp; 4.5&amp;nbsp; &amp;nbsp; 5.3&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp;1.3&amp;nbsp; &amp;nbsp; &amp;nbsp;2.2&amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4.4&amp;nbsp; &amp;nbsp; 5.5&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp;1.4&amp;nbsp; &amp;nbsp; &amp;nbsp;2.3&amp;nbsp; &amp;nbsp; 3.6&amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5.1&lt;/P&gt;&lt;P&gt;5&amp;nbsp; &amp;nbsp;1.8&amp;nbsp; &amp;nbsp; &amp;nbsp;2.9&amp;nbsp; &amp;nbsp; 3.0&amp;nbsp; &amp;nbsp; 4.7&amp;nbsp; &amp;nbsp; .&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;How could I move one row up for each variable (one row less in the end), and the result I wanted is:&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp;X1&amp;nbsp; &amp;nbsp; X2&amp;nbsp; &amp;nbsp; &amp;nbsp;X3&amp;nbsp; &amp;nbsp; X4&amp;nbsp; &amp;nbsp; X5 ...... Xn&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp;1.2&amp;nbsp; &amp;nbsp; &amp;nbsp;2.1&amp;nbsp; &amp;nbsp; 3.1&amp;nbsp; &amp;nbsp; 4.1&amp;nbsp; &amp;nbsp;5.1&amp;nbsp; .....&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp;1.3&amp;nbsp; &amp;nbsp; &amp;nbsp;2.2&amp;nbsp; &amp;nbsp; 3.3&amp;nbsp; &amp;nbsp; 4.5&amp;nbsp; &amp;nbsp;5.3&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp;1.4&amp;nbsp; &amp;nbsp; &amp;nbsp;2.3&amp;nbsp; &amp;nbsp; 3.6&amp;nbsp; &amp;nbsp; 4.4&amp;nbsp; &amp;nbsp;5.5&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp;1.8&amp;nbsp; &amp;nbsp; &amp;nbsp;2.9&amp;nbsp; &amp;nbsp; 3.0&amp;nbsp; &amp;nbsp; 4.7&amp;nbsp; &amp;nbsp;5.1&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 21:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624666#M20149</guid>
      <dc:creator>sarahfung532</dc:creator>
      <dc:date>2020-02-13T21:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624668#M20150</link>
      <description>&lt;P&gt;This isn't very elegant, but it will work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have (keep=x1 where=(x1 &amp;gt; .));
   set have (keep=x2 where=(x2 &amp;gt; .));
   ...
   set have (keep=xn where=(xn &amp;gt; .));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Feb 2020 22:06:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624668#M20150</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-02-13T22:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624670#M20151</link>
      <description>&lt;P&gt;Thank you for your quick response! It would work for small data set. But my data have 10,000 observations and over 800 same type of variables (x1 to x800), so the "set" statement won't be so practical in here ...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 22:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624670#M20151</guid>
      <dc:creator>sarahfung532</dc:creator>
      <dc:date>2020-02-13T22:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624673#M20152</link>
      <description>&lt;P&gt;HI&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312056"&gt;@sarahfung532&lt;/a&gt;&amp;nbsp; Is your ID numeric? If yes, i will take a shot a with multi dim array. If not, I have to think of something different&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 22:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624673#M20152</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-13T22:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624675#M20153</link>
      <description>&lt;P&gt;It becomes more practical if you let macro language do the typing.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro nonmissing (n=);
   %local i;
   %do i=1 %to &amp;amp;n;
      set have (keep=x&amp;amp;i where=(x&amp;amp;i &amp;gt; .));
   %end;
%mend nonmissing;

data want;
   %nonmissing (n=800)
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Feb 2020 22:37:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624675#M20153</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-02-13T22:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624677#M20154</link>
      <description>&lt;P&gt;Are you sure?&amp;nbsp; That looks like some type of array with missing values along the diagonal.&amp;nbsp; Are you sure that eliminating the missing values won't put the values in the wrong place? Are you sure that you shouldn't instead be moving the values one column to the left instead?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 22:45:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624677#M20154</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-13T22:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624686#M20155</link>
      <description>&lt;P&gt;Hi again&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312056"&gt;@sarahfung532&lt;/a&gt;&amp;nbsp; I am not sure how rolling up leading to exluding ID makes sense if you may clarify, nonetheless here is an approach&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input ID   X1    X2     X3    X4    X5;
cards;
1    .        2.1    3.1    4.1    5.1 
2   1.2     .        3.3    4.5    5.3
3   1.3     2.2    .        4.4    5.5  
4   1.4     2.3    3.6     .       5.1
5   1.8     2.9    3.0    4.7    .
;

data want;
 do _n_=1 by 1 until(z);
  set have end=z;
  array t(5,5) _temporary_;
  array u x1-x5;
  do over u;
   t(_n_,_i_)=u;
  end;
 end;
 do _n_=1 to 5;
  do _i_=1 to dim(t,1)-1;
   if t(_i_,_n_)=. then do;
    t(_i_,_n_)=t(_i_+1,_n_);
    t(_i_+1,_n_)=.;
   end;
  end;
 end;
 do _n_=1 to dim(t,1)-1;
  do over u;
   u=t(_n_,_i_);
  end;
  output;
 end;
 drop id;
run;
/*And if you want the ID rolled up as it seems your output exludes ID5,
the following does it*/
data want_with_ID;
 do _n_=1 by 1 until(z);
  set have end=z;
  array t(5,5) _temporary_ ;
  array u x1-x5;
  array v(5) _temporary_;
  v(_n_)=id;
  do over u;
   t(_n_,_i_)=u;
  end;
 end;
 do _n_=1 to 5;
  do _i_=1 to dim(t,1)-1;
   if t(_i_,_n_)=. then do;
    t(_i_,_n_)=t(_i_+1,_n_);
    t(_i_+1,_n_)=.;
   end;
  end;
 end;
 do _n_=1 to dim(t,1)-1;
  id=v(_n_);
  do over u;
   u=t(_n_,_i_);
  end;
  output;
 end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And if your ID is char, please make the V array, a temp array with a $ length like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array v(5)$32 _temporary_;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Feb 2020 23:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624686#M20155</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-13T23:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624690#M20156</link>
      <description>&lt;P&gt;The data actually came from a Deming Jackknife procedure, which the diagonal missing values are useless. We only need the non-missing values for further calculations.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 23:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624690#M20156</guid>
      <dc:creator>sarahfung532</dc:creator>
      <dc:date>2020-02-13T23:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624692#M20157</link>
      <description>&lt;P&gt;Thank you! I will try that later.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 23:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624692#M20157</guid>
      <dc:creator>sarahfung532</dc:creator>
      <dc:date>2020-02-13T23:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624695#M20158</link>
      <description>&lt;P&gt;I will try your code tomorrow. Thank you very much! The diagonal missing data was from a Jackknife procedure for Deming regression analysis. We don't care the ID match up or not, we need to do a matrix calculations after, which not allow missing values in there. That's why I need help to remove only the missing values. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 23:27:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624695#M20158</guid>
      <dc:creator>sarahfung532</dc:creator>
      <dc:date>2020-02-13T23:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624697#M20159</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;We don't care the ID match up or not,"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That makes it a piece of cake. Feel free to come back to us should you need any clarification tomorrow. It's no biggie. Of course the code provided by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp; is very convenient, however the multidim array isn't hard either once you know how to reference the elements. All the best!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2020 23:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624697#M20159</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-02-13T23:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624703#M20160</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/312056"&gt;@sarahfung532&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I will try your code tomorrow. Thank you very much! The diagonal missing data was from a Jackknife procedure for Deming regression analysis. We don't care the ID match up or not, we need to do a matrix calculations after, which not allow missing values in there. That's why I need help to remove only the missing values. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Still makes no sense to me. The normal meaning of a dataset is that a single observation represents that value of the variables for a single event/sample/person.&amp;nbsp; Moving the values from the next observation for one of the variables makes no sense.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you just need to eliminate the non-missing values for your matrix operations to work then replace the missing values with some constant. Like zero or 1&amp;nbsp; or the row mean or the column mean that will not impact the operation.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 00:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624703#M20160</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-14T00:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: move one row up for all variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624897#M20180</link>
      <description>&lt;P&gt;You code works beautifully!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I tried it on my data which is 10,000 observations and over&amp;nbsp; 50,000 variables, and the who procedure only took less than 2 minutes! Thank you so much!!!&lt;/P&gt;</description>
      <pubDate>Fri, 14 Feb 2020 17:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/move-one-row-up-for-all-variables/m-p/624897#M20180</guid>
      <dc:creator>sarahfung532</dc:creator>
      <dc:date>2020-02-14T17:19:42Z</dc:date>
    </item>
  </channel>
</rss>

