<?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 Data Up in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251945#M47698</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b c d;
cards;
1 . . .
2 1 . .
3 2 1 .
4 3 2 1
;
run;
data _null_;
 set sashelp.vcolumn(where=(libname='WORK' and memname='HAVE')) end=last;
 if _n_ eq 1 then call execute('data want;merge ');
 call execute(catt('have(keep=',name,' where=(',name,' is not missing))'));
 if last then call execute(';run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Feb 2016 02:38:43 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-02-24T02:38:43Z</dc:date>
    <item>
      <title>Move Data Up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251892#M47680</link>
      <description>&lt;P&gt;Good evening everyone! I am hoping someone can help me out. I need to get my data in a new format so that I can analyze it a certain way. Currently the data&amp;nbsp;that I need to move up the specific cells when they are missing. The trick to this is I have hundreds of variables, and the number of variables need to change every month so I need it to be dynamic. I have been messing around with arrays and do loops, using macro variables, but can't get it. The only thing I can think of is to create a dataset with each variable then merge it back together but I need to automate it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is what I&amp;nbsp;have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2002i31AEEDDE89FE7522/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I need it to look like this:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/2003iAF5B7F40BB24F06B/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture1.PNG" title="Capture1.PNG" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 22:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251892#M47680</guid>
      <dc:creator>ChelseyKate</dc:creator>
      <dc:date>2016-02-23T22:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Move Data Up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251893#M47681</link>
      <description>&lt;P&gt;Can you back your process a step, how are you generating that file? Change that process...If you have the code for it, showing that would be helpful as would the original data format.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2016 22:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251893#M47681</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-23T22:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Move Data Up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251897#M47684</link>
      <description>The format of the data before this is multiple rows per record of amount of dollars recovered by date. So I used Proc SQL to sum the recoveries up by month and then divide it by total loss to get percentage. So it's formatted this way because it's grouped by month. &lt;BR /&gt;</description>
      <pubDate>Tue, 23 Feb 2016 23:04:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251897#M47684</guid>
      <dc:creator>ChelseyKate</dc:creator>
      <dc:date>2016-02-23T23:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: Move Data Up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251945#M47698</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b c d;
cards;
1 . . .
2 1 . .
3 2 1 .
4 3 2 1
;
run;
data _null_;
 set sashelp.vcolumn(where=(libname='WORK' and memname='HAVE')) end=last;
 if _n_ eq 1 then call execute('data want;merge ');
 call execute(catt('have(keep=',name,' where=(',name,' is not missing))'));
 if last then call execute(';run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2016 02:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251945#M47698</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-02-24T02:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Move Data Up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251947#M47700</link>
      <description>&lt;P&gt;Here is IML code. If you have lots of variables, IML would save you lots of time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b c d;
cards;
1 . . .
2 1 . .
3 2 1 .
4 3 2 1
;
run;
proc iml;
use have;
read all var _all_ into x[c=vname];
close;
y=j(nrow(x),ncol(x),.);
do i=1 to ncol(x);
 idx_x=loc(x[,i]^=.); 
 idx_y=1:ncol(idx_x);
 y[idx_y,i]=x[idx_x,i];
end;
create want from y[c=vname];
append from y;
close;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2016 02:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/251947#M47700</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-02-24T02:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: Move Data Up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/252033#M47732</link>
      <description>&lt;P&gt;Thanks! This didn't seem to work and is running through every dataset I have in every library....&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 13:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/252033#M47732</guid>
      <dc:creator>ChelseyKate</dc:creator>
      <dc:date>2016-02-24T13:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Move Data Up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/252262#M47848</link>
      <description>&lt;P&gt;What do you mean it didn't work out ? Here is the code go through all the tables in WORK library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input a b c d;
cards;
1 . . .
2 1 . .
3 2 1 .
4 3 2 1
;
run;
data have1;
input a b c d;
cards;
1 . . .
2 1 . .
3 2 1 .
5 3 2 1
;
run;
data _null_;
 set sashelp.vcolumn(where=(libname='WORK') keep=memname libname name) end=last;
 by memname;
 if first.memname then call execute(catt('data new_',memname,';merge '));
 call execute(catt(memname,'(keep=',name,' where=(',name,' is not missing))'));
 if last.memname then call execute(';run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Feb 2016 00:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/252262#M47848</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-02-25T00:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Move Data Up</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/252264#M47849</link>
      <description>&lt;P&gt;Here is IML code for going through all the tables in WORK library . much faster than data step.&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 a b c d;
cards;
1 . . .
2 1 . .
3 2 1 .
4 3 2 1
;
run;
data have1;
input a b c d;
cards;
1 . . .
2 1 . .
3 2 1 .
5 3 2 1
;
run;

proc iml;
memname=datasets('WORK');
new_memname=cats('new_',memname);
do j=1 to nrow(memname);
 use (memname[j]);
 read all var _all_ into x[c=vname];
 close;
 
 y=j(nrow(x),ncol(x),.);
 do i=1 to ncol(x);
  idx_x=loc(x[,i]^=.); 
  idx_y=1:ncol(idx_x);
  y[idx_y,i]=x[idx_x,i];
 end;

create (new_memname[j])from y[c=vname];
append from y;
close;
end;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Feb 2016 01:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Move-Data-Up/m-p/252264#M47849</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-02-25T01:06:47Z</dc:date>
    </item>
  </channel>
</rss>

