<?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: How to rename to rename multiple variables to one variable name in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-rename-to-rename-multiple-variables-to-one-variable-name/m-p/690555#M24752</link>
    <description>&lt;P&gt;You have a dataset with 4 variables, each containing a value.&amp;nbsp; You can't RENAME 4 variables to the same name.&amp;nbsp; You apparently want to do something else.&amp;nbsp; &amp;nbsp;For instance, in the transposed data set, if you always have only one valid data value among the 4 variables, with the other 3 always missing, you could do something like this in a DATA step reading in the transposed data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
   set transposed;
   new_var=coalesce(co1,co2,col3,col4);
   format new_var date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The coalesce function takes the first non-missing value from the list of arguments.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Oct 2020 19:03:18 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2020-10-09T19:03:18Z</dc:date>
    <item>
      <title>How to rename to rename multiple variables to one variable name</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-rename-to-rename-multiple-variables-to-one-variable-name/m-p/690545#M24746</link>
      <description>&lt;TABLE border="1" width="74.65105013743559%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD colspan="6" width="91.0803324099723%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="20%"&gt;ID&amp;nbsp;&lt;/TD&gt;
&lt;TD width="20%"&gt;COL1&lt;/TD&gt;
&lt;TD width="20%"&gt;CoL2&lt;/TD&gt;
&lt;TD width="20%"&gt;COL3&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5.540166204986149%"&gt;COL4&lt;/TD&gt;
&lt;TD width="5.540166204986149%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="20%"&gt;1&lt;/TD&gt;
&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="20%"&gt;04/03/2020&lt;/TD&gt;
&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5.540166204986149%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="5.540166204986149%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;I got a table like this after using proc transpose to convert horizontal variable to vertical. I wanted to know how to rename the variables COL1 COL2 COL3 COL4 to one variable name ''Date".&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 18:17:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-rename-to-rename-multiple-variables-to-one-variable-name/m-p/690545#M24746</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-10-09T18:17:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename to rename multiple variables to one variable name</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-rename-to-rename-multiple-variables-to-one-variable-name/m-p/690555#M24752</link>
      <description>&lt;P&gt;You have a dataset with 4 variables, each containing a value.&amp;nbsp; You can't RENAME 4 variables to the same name.&amp;nbsp; You apparently want to do something else.&amp;nbsp; &amp;nbsp;For instance, in the transposed data set, if you always have only one valid data value among the 4 variables, with the other 3 always missing, you could do something like this in a DATA step reading in the transposed data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
   set transposed;
   new_var=coalesce(co1,co2,col3,col4);
   format new_var date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The coalesce function takes the first non-missing value from the list of arguments.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 19:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-rename-to-rename-multiple-variables-to-one-variable-name/m-p/690555#M24752</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-10-09T19:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to rename to rename multiple variables to one variable name</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-rename-to-rename-multiple-variables-to-one-variable-name/m-p/690562#M24755</link>
      <description>&lt;P&gt;Or alternatively, you can transpose your data so that you have two columns: ID and Date, with a row for each date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    input id col1 :mmddyy10. col2 :mmddyy10. col3 :mmddyy10. col4 :mmddyy10.;
    format col1-col4 mmddyy10.;
    datalines;
    1 . 04/03/2020 . .
    ;
run;

proc transpose data=have out=want (drop=_: rename=(col1 = date));
    by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;id	date
1	.
1	04/03/2020
1	.
1	.&lt;/PRE&gt;
&lt;P&gt;It all depends on what you want, and whether or not there can be more than one date per ID, like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;mentioned.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 19:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-rename-to-rename-multiple-variables-to-one-variable-name/m-p/690562#M24755</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-10-09T19:23:41Z</dc:date>
    </item>
  </channel>
</rss>

