<?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: changing column into rows keeping 1 row constant and repeated in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/597584#M18229</link>
    <description>&lt;P&gt;in reference to&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;Maturity &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;char&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;vname&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;if my variable name is "mm_100" then how do i extract the number from it ?&lt;/P&gt;&lt;P&gt;for example in this case maturity=100 when get the rows&lt;/P&gt;</description>
    <pubDate>Fri, 18 Oct 2019 01:26:33 GMT</pubDate>
    <dc:creator>Takdir</dc:creator>
    <dc:date>2019-10-18T01:26:33Z</dc:date>
    <item>
      <title>changing column into rows keeping 1 row constant and repeated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596745#M18193</link>
      <description>&lt;P&gt;basically I have multiple column for a given date. But i wish to have them as rows keeping the date column. Example : this is the table I was given:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;X&amp;nbsp; maturity&lt;/TD&gt;&lt;TD&gt;Y maturity&lt;/TD&gt;&lt;TD&gt;Z maturity&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01-Mar&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-Mar&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03-Mar&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this is what I want:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;maturity&lt;/TD&gt;&lt;TD&gt;Rate&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01-Mar&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01-Mar&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01-Mar&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-Mar&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-Mar&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02-Mar&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03-Mar&lt;/TD&gt;&lt;TD&gt;X&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03-Mar&lt;/TD&gt;&lt;TD&gt;Y&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03-Mar&lt;/TD&gt;&lt;TD&gt;Z&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 05:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596745#M18193</guid>
      <dc:creator>Takdir</dc:creator>
      <dc:date>2019-10-16T05:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: changing column into rows keeping 1 row constant and repeated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596747#M18194</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Date $ Xmaturity Ymaturity Zmaturity;
datalines;
01-Mar 1 2 4
02-Mar 5 8 9
03-Mar 3 5 7
;

proc transpose data=have out=want(rename=(_name_=Maturity col1=rate));
    by Date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 05:20:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596747#M18194</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-16T05:20:42Z</dc:date>
    </item>
    <item>
      <title>Re: changing column into rows keeping 1 row constant and repeated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596748#M18195</link>
      <description>&lt;P&gt;Or&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Date $ Xmaturity Ymaturity Zmaturity;
datalines;
01-Mar 1 2 4
02-Mar 5 8 9
03-Mar 3 5 7
;

data want;
    set have;
    array _{3} Xmaturity Ymaturity Zmaturity;
    do i=1 to dim(_);
        Maturity = char(vname(_[i]), 1);
        Rate     = _[i];
        output;
    end;

    keep Date Maturity Rate;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Date    Maturity Rate
01-Mar	X	     1
01-Mar	Y	     2
01-Mar	Z	     4
02-Mar	X	     5
02-Mar	Y	     8
02-Mar	Z	     9
03-Mar	X	     3
03-Mar	Y	     5
03-Mar	Z	     7&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 05:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596748#M18195</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-16T05:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: changing column into rows keeping 1 row constant and repeated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596754#M18196</link>
      <description>&lt;P&gt;is the value 3 after the array function for&amp;nbsp;Xmaturity Ymaturity Zmaturity or is it for the number of dates that i had?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 06:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596754#M18196</guid>
      <dc:creator>Takdir</dc:creator>
      <dc:date>2019-10-16T06:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: changing column into rows keeping 1 row constant and repeated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596755#M18197</link>
      <description>&lt;P&gt;It is the number of elements in the array (3 variables: Xmaturity, Ymaturity and Zmaturity). You could put an asterisk in there instead like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    array _{*} Xmaturity Ymaturity Zmaturity;
    do i=1 to dim(_);
        Maturity = char(vname(_[i]), 1);
        Rate     = _[i];
        output;
    end;

    keep Date Maturity Rate;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 06:14:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596755#M18197</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-10-16T06:14:20Z</dc:date>
    </item>
    <item>
      <title>Re: changing column into rows keeping 1 row constant and repeated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596756#M18198</link>
      <description>&lt;P&gt;Thank you. You really solved a big problem of mine&amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://communities.sas.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 06:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/596756#M18198</guid>
      <dc:creator>Takdir</dc:creator>
      <dc:date>2019-10-16T06:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: changing column into rows keeping 1 row constant and repeated</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/597584#M18229</link>
      <description>&lt;P&gt;in reference to&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;Maturity &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;char&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;vname&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;_&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;if my variable name is "mm_100" then how do i extract the number from it ?&lt;/P&gt;&lt;P&gt;for example in this case maturity=100 when get the rows&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 01:26:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/changing-column-into-rows-keeping-1-row-constant-and-repeated/m-p/597584#M18229</guid>
      <dc:creator>Takdir</dc:creator>
      <dc:date>2019-10-18T01:26:33Z</dc:date>
    </item>
  </channel>
</rss>

