<?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: Retain Multiple Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retain-Multiple-Variables/m-p/296641#M62201</link>
    <description>&lt;PRE&gt;
data temp;
input ID x y z;
cards;
1 25 . .
1 . 35 .
1 . . 40
2 30 . .
2 . 25 .
3 50 . .
;
run;
proc means data=temp noprint;
by id;
var x y z ;
output out=temp1 sum=;
run;
data want;
 set temp1(drop=_type_);
 do i=1 to _freq_;
  output;
 end;
 drop i _freq_;
run;

&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Sep 2016 06:26:58 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-09-06T06:26:58Z</dc:date>
    <item>
      <title>Retain Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Multiple-Variables/m-p/296581#M62168</link>
      <description>&lt;P&gt;I want to retain all the variables. Please see the raw data and desired data below -&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/4838iD56692AAAFDBC092/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="img1.png" title="img1.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
input ID x y z;
cards;
1 25 . .
1 . 35 .
1 . . 40
2 30 . .
2 . 25 .
3 50 . .
;
run;

data temp2;
set temp;
by ID;
retain x1 0;
if first.ID then X1=x;
else X1=X1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have done it for variable x but i am unable to do it for other variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Sep 2016 17:27:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Multiple-Variables/m-p/296581#M62168</guid>
      <dc:creator>Ujjawal</dc:creator>
      <dc:date>2016-09-05T17:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Multiple-Variables/m-p/296590#M62173</link>
      <description>&lt;P&gt;A double DO UNTIL() can perform this operation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
input ID x y z;
cards;
1 25 . .
1 . 35 .
1 . . 40
2 30 . .
2 . 25 .
3 50 . .
;

data want;
array _a{3} x y z;
array _b{3};
do until(last.ID);
    set temp; by ID;
    do i = 1 to dim(_a);
        _b{i} = coalesce(_b{i}, _a{i});
        end;
    end;
do until(last.ID);
    set temp; by ID;
    do i = 1 to dim(_a);
        _a{i} = _b{i};
        end;
    output;
    end;
drop i _b:;
run;

proc print; run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Sep 2016 19:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Multiple-Variables/m-p/296590#M62173</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-05T19:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Retain Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-Multiple-Variables/m-p/296641#M62201</link>
      <description>&lt;PRE&gt;
data temp;
input ID x y z;
cards;
1 25 . .
1 . 35 .
1 . . 40
2 30 . .
2 . 25 .
3 50 . .
;
run;
proc means data=temp noprint;
by id;
var x y z ;
output out=temp1 sum=;
run;
data want;
 set temp1(drop=_type_);
 do i=1 to _freq_;
  output;
 end;
 drop i _freq_;
run;

&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Sep 2016 06:26:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-Multiple-Variables/m-p/296641#M62201</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-09-06T06:26:58Z</dc:date>
    </item>
  </channel>
</rss>

