<?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: SAS: replicate rows and iterate over columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785344#M250630</link>
    <description>&lt;P&gt;"V1" or "W1" are not numeric values, so you cannot use them in calculations. Please post your example data in unambiguous manner, which means in a&amp;nbsp;&lt;STRONG&gt;data step with datalines (&lt;FONT color="#FF0000"&gt;do not skip this!&lt;FONT color="#000000"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt; so we know exactly what we have to deal with in terms of values and variable attributes.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Dec 2021 10:01:28 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-12-10T10:01:28Z</dc:date>
    <item>
      <title>SAS: replicate rows and iterate over columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785340#M250626</link>
      <description>&lt;P&gt;I'd like to replicate and modify specific rows in the table.&lt;/P&gt;&lt;P&gt;before:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;xyz_id | letter | Col_1 | Col_2|
1 | Z | V1 | W1 |
2 | Z | V2 | W2 |
3 | Z | V3 | W3 |&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;after:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;xyz_id | letter | Col_1 | Col_2|
1 | A | V1.1 | W1.1 |
1 | B | V1.1 | W1.1 |
1 | C | V1.1 | W1.1 |
2 | A | V2.1 | W2.1 |
2 | B | V2.1 | W2.1 |
2 | C | V2.1 | W2.1 |
3 | A | V3.1 | W3.1 |
3 | B | V3.1 | W3.1 |
3 | C | V3.1 | W3.1 |&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've prepared the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data test;&lt;BR /&gt;input xyz_id$ letter$ Col_1 Col_2;&lt;BR /&gt;cards;&lt;BR /&gt;1 Z 0.1895 . &lt;BR /&gt;2 Z 0.2208 0.2432&lt;BR /&gt;3 Z 0.3696 0.3739&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data test2;
        set test;
        
        array letters {8} $8 _temporary_ ('A', 'B', 'C');
        array weights {8}  _temporary_ (1,2,3);
        array nvars {2} Col_1 Col_2;

        do i = 1 to 8;
            letter = letters(i);

            do j=1 to 2;
                nvar{j} = nvar{j} * weights(i);
            end;

            output;
        end;
          drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;but it doesn't work. Any suggestions?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 10:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785340#M250626</guid>
      <dc:creator>ToRsy</dc:creator>
      <dc:date>2021-12-10T10:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS: replicate rows and iterate over columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785344#M250630</link>
      <description>&lt;P&gt;"V1" or "W1" are not numeric values, so you cannot use them in calculations. Please post your example data in unambiguous manner, which means in a&amp;nbsp;&lt;STRONG&gt;data step with datalines (&lt;FONT color="#FF0000"&gt;do not skip this!&lt;FONT color="#000000"&gt;)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#FF0000"&gt;&lt;FONT color="#000000"&gt; so we know exactly what we have to deal with in terms of values and variable attributes.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 10:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785344#M250630</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-10T10:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS: replicate rows and iterate over columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785348#M250631</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; - I added the data step - sorry for the inconvenience&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 10:25:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785348#M250631</guid>
      <dc:creator>ToRsy</dc:creator>
      <dc:date>2021-12-10T10:25:20Z</dc:date>
    </item>
    <item>
      <title>Re: SAS: replicate rows and iterate over columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785359#M250632</link>
      <description>&lt;P&gt;Wouldn't an SQL product be what you need?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input xyz_id$ letter$ Col_1 Col_2;
cards;
1 Z 0.1895 . 
2 Z 0.2208 0.2432
3 Z 0.3696 0.3739
;
run;

data letters;
input letter $;
cards;
A
B
C
;
run;

proc sql;
create table test2 as
select 
 a.xyz_id
,b.letter
,a.Col_1
,a.Col_2
from 
test as a, letters as b
order by
 a.xyz_id
,b.letter
;
quit;
proc print data = test2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 10:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785359#M250632</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-12-10T10:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS: replicate rows and iterate over columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785360#M250633</link>
      <description>&lt;P&gt;Hi Bart, not really. There might be several different Col_. I'm looking for a tool.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 11:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785360#M250633</guid>
      <dc:creator>ToRsy</dc:creator>
      <dc:date>2021-12-10T11:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS: replicate rows and iterate over columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785361#M250634</link>
      <description>&lt;P&gt;What do you mean by "&lt;SPAN&gt;&amp;nbsp;several different Col_&lt;/SPAN&gt;" ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 11:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785361#M250634</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-12-10T11:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS: replicate rows and iterate over columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785362#M250635</link>
      <description>&lt;P&gt;Does each letter (a b c) can have a weight assigned to it? Like here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input xyz_id$ letter$ Col_1 Col_2;
cards;
1 Z 0.1895 . 
2 Z 0.2208 0.2432
3 Z 0.3696 0.3739
;
run;

data letters;
input letter $ weight;
cards;
A 10
B 20
C 30
;
run;

proc sql;
create table test2 as
select 
 a.xyz_id
,b.letter
,a.Col_1 * b.weight as Col_1
,a.Col_2 * b.weight as Col_2
from 
test as a, letters as b
order by
 a.xyz_id
,b.letter
;
quit;
proc print data = test2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 11:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785362#M250635</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-12-10T11:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS: replicate rows and iterate over columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785410#M250648</link>
      <description>&lt;P&gt;OK, so, based on this dataset:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input xyz_id$ letter$ Col_1 Col_2;
cards;
1 Z 0.1895 . 
2 Z 0.2208 0.2432
3 Z 0.3696 0.3739
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;what do you expect to get?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 14:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-replicate-rows-and-iterate-over-columns/m-p/785410#M250648</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-12-10T14:36:45Z</dc:date>
    </item>
  </channel>
</rss>

