<?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: Repeat a value in different rows with the same key in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519408#M3790</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input key $ d1 d2 d3;
cards;
1 1 . .
1 . 2 .
1 . . 3
;
run;
proc summary data=have nway;
class key;
var _numeric_;
output out=temp sum=;
run;
data want;
 set temp;
 do i=1 to _freq_;
  output;
 end;
 drop i _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Dec 2018 13:30:06 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-12-07T13:30:06Z</dc:date>
    <item>
      <title>Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519399#M3785</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Captura.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25455i636D91357BAA2F87/image-size/large?v=v2&amp;amp;px=999" role="button" title="Captura.PNG" alt="Captura.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this situations and i would like to repeat the values in all of the rows with the same key. Anyone can help me?&lt;/P&gt;&lt;P&gt;For example in the column D200306 i need the value 661.35 in the seven rows for that key.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 13:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519399#M3785</guid>
      <dc:creator>Sweetplanet</dc:creator>
      <dc:date>2018-12-07T13:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519400#M3786</link>
      <description>&lt;P&gt;Just to be clear, you mean in the seven &lt;EM&gt;&lt;STRONG&gt;rows&lt;/STRONG&gt; &lt;/EM&gt;for that key, right?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 13:18:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519400#M3786</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-07T13:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519402#M3787</link>
      <description>&lt;P&gt;Yes, for that key.&lt;/P&gt;&lt;P&gt;I have a lot of groups of rows with differents keys.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 13:21:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519402#M3787</guid>
      <dc:creator>Sweetplanet</dc:creator>
      <dc:date>2018-12-07T13:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519407#M3789</link>
      <description>&lt;P&gt;So you want&amp;nbsp;&lt;SPAN&gt;661.35 to replace every missing value I can see here?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Or do you want&amp;nbsp;661.35 to replace all the missing values in the first row, 604.52 to&amp;nbsp;replace all the missing values in the second row and so on?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 13:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519407#M3789</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-07T13:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519408#M3790</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input key $ d1 d2 d3;
cards;
1 1 . .
1 . 2 .
1 . . 3
;
run;
proc summary data=have nway;
class key;
var _numeric_;
output out=temp sum=;
run;
data want;
 set temp;
 do i=1 to _freq_;
  output;
 end;
 drop i _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Dec 2018 13:30:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519408#M3790</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-12-07T13:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519409#M3791</link>
      <description>&lt;P&gt;You can use proc summary to get one row for that data with all the values populated.&amp;nbsp; Something like:&lt;/P&gt;
&lt;PRE&gt;proc summary data=have;
  class key;
  var d:;
  output out=want sum= / autoname;
run;&lt;/PRE&gt;
&lt;P&gt;Or do you mean you still want 7 rows in the output dataset?&amp;nbsp; If so then that is trickier.&amp;nbsp; Probably need to normalise the data to get something like:&lt;BR /&gt;key&amp;nbsp; &amp;nbsp; col&amp;nbsp; &amp;nbsp;val&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then&amp;nbsp;sort by key removing missings, then merging that back onto the data, setting where missing to be the merged value.&amp;nbsp; Then transpose up.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Post test data in the form of a datastep!!&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;/U&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not going to type in test data just to have something to work on.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 13:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519409#M3791</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-12-07T13:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519410#M3792</link>
      <description>661.35 in every missing value by column. I mean, in the column D200306 the value 661.35 in each row, the value 604.51 in the column D200307 in each row and so on.</description>
      <pubDate>Fri, 07 Dec 2018 13:33:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519410#M3792</guid>
      <dc:creator>Sweetplanet</dc:creator>
      <dc:date>2018-12-07T13:33:37Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519411#M3793</link>
      <description>&lt;P&gt;If the latter is the case then do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input key $8. D200306 D200307 D200308;
datalines;
BRR9934X 1 . .
BRR9934X . 1 .
BRR9934X . . 1
;

data want(drop=i);
   set have nobs=nobs ;
   array vars{*} D2003:;
   do i=1 to dim(vars);
      if vars[i]=. then vars[i]=coalesce(of vars[*]);
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Dec 2018 13:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519411#M3793</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-07T13:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519412#M3794</link>
      <description>Really in the example i show you, i would like to have only one row for key and the values thats appears in the columns only in one row.</description>
      <pubDate>Fri, 07 Dec 2018 13:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519412#M3794</guid>
      <dc:creator>Sweetplanet</dc:creator>
      <dc:date>2018-12-07T13:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519422#M3802</link>
      <description>&lt;P&gt;Fix your data structure on the way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose
  data=have
  out=trans (
    rename=(_name_=period)
  )
;
by key;
var d:;
run;

data want;
set trans;
value = coalesce(of col:);
drop col:;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That way you get a nice, long dataset that's easy to work with. See Maxim 19.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 13:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519422#M3802</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-07T13:57:47Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519431#M3806</link>
      <description>&lt;P&gt;May I challenge ther requirement.&lt;/P&gt;
&lt;P&gt;If I unserstand you correctly, you wish to store seven rows with identical values in all columns?&lt;/P&gt;
&lt;P&gt;What is the use of that?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IMO condensng to one row, or transposing so you'll have something like ID, DC_num, and DC_val (seven rows) will give you uniqueness and a normaized data structure.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 14:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519431#M3806</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2018-12-07T14:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Repeat a value in different rows with the same key</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519448#M3808</link>
      <description>&lt;P&gt;If you want just one row per KEY, this becomes a much simpler problem.&amp;nbsp; Assuming your data is sorted by KEY:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;update have (obs=0) have;&lt;/P&gt;
&lt;P&gt;by key;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 15:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Repeat-a-value-in-different-rows-with-the-same-key/m-p/519448#M3808</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-07T15:40:35Z</dc:date>
    </item>
  </channel>
</rss>

