<?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 can i prefix the variable? in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-i-prefix-the-variable/m-p/6181#M2469</link>
    <description>since you want a common suffix, depending on the source data set, I don't understand why having many names causes the rename restriction, nor the suggestion of using an array. The "data dictionary" tables in a SAS environment, allow the names to be treated as data and stored for use in a macro variable, like[pre]&lt;BR /&gt;
proc contents data= your.dataset1 noprint out= names1; run;&lt;BR /&gt;
proc contents data= your.dataset2 noprint out= names2; run;&lt;BR /&gt;
proc sql ;&lt;BR /&gt;
  select trim( name) !! '=' !! trim( name) !! '_1' &lt;BR /&gt;
    into :rename1  separated by ' '&lt;BR /&gt;
    from names1&lt;BR /&gt;
   where lowcase(name) ne "key_column_name"&lt;BR /&gt;
        ;&lt;BR /&gt;
  select trim( name) !! '=' !! trim( name) !! '_2' &lt;BR /&gt;
    into :rename2  separated by ' '&lt;BR /&gt;
    from names2&lt;BR /&gt;
   where lowcase(name) ne "key_column_name"&lt;BR /&gt;
        ;&lt;BR /&gt;
quit;[/pre]&lt;BR /&gt;
That prepares the rename information without you having to name any columns, except logical exclusions from renaming, like the key fields.&lt;BR /&gt;
Use this rename information in your merge step, like[pre]&lt;BR /&gt;
data merged_data ;&lt;BR /&gt;
   merge your.dataset1( rename= (&amp;amp;rename1)) &lt;BR /&gt;
         your.dataset2( rename= (&amp;amp;rename2)) ;&lt;BR /&gt;
     by key_column_name ;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
So, is there some real reason to use arrays and avoid the rename processing ?&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
    <pubDate>Mon, 07 Jan 2008 14:43:02 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-01-07T14:43:02Z</dc:date>
    <item>
      <title>How can i prefix the variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-i-prefix-the-variable/m-p/6178#M2466</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have on question.I have two data sets with same variable names,How to merge  two data sets with diff names,without using reaname function .by using arrays how can do?&lt;BR /&gt;
Dataset 1,&lt;BR /&gt;
&lt;BR /&gt;
X Y&lt;BR /&gt;
a 23&lt;BR /&gt;
b 24&lt;BR /&gt;
&lt;BR /&gt;
dataset2&lt;BR /&gt;
&lt;BR /&gt;
X Y&lt;BR /&gt;
x 234&lt;BR /&gt;
s 123&lt;BR /&gt;
&lt;BR /&gt;
output&lt;BR /&gt;
&lt;BR /&gt;
x1 y1 x2 y2&lt;BR /&gt;
a 23 x 234&lt;BR /&gt;
b 24 s 123.</description>
      <pubDate>Mon, 07 Jan 2008 09:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-i-prefix-the-variable/m-p/6178#M2466</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-07T09:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can i prefix the variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-i-prefix-the-variable/m-p/6179#M2467</link>
      <description>why the restrictions ?</description>
      <pubDate>Mon, 07 Jan 2008 10:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-i-prefix-the-variable/m-p/6179#M2467</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-07T10:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can i prefix the variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-i-prefix-the-variable/m-p/6180#M2468</link>
      <description>Becase in our dataset there are 25 field names.</description>
      <pubDate>Mon, 07 Jan 2008 12:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-i-prefix-the-variable/m-p/6180#M2468</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-07T12:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can i prefix the variable?</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-i-prefix-the-variable/m-p/6181#M2469</link>
      <description>since you want a common suffix, depending on the source data set, I don't understand why having many names causes the rename restriction, nor the suggestion of using an array. The "data dictionary" tables in a SAS environment, allow the names to be treated as data and stored for use in a macro variable, like[pre]&lt;BR /&gt;
proc contents data= your.dataset1 noprint out= names1; run;&lt;BR /&gt;
proc contents data= your.dataset2 noprint out= names2; run;&lt;BR /&gt;
proc sql ;&lt;BR /&gt;
  select trim( name) !! '=' !! trim( name) !! '_1' &lt;BR /&gt;
    into :rename1  separated by ' '&lt;BR /&gt;
    from names1&lt;BR /&gt;
   where lowcase(name) ne "key_column_name"&lt;BR /&gt;
        ;&lt;BR /&gt;
  select trim( name) !! '=' !! trim( name) !! '_2' &lt;BR /&gt;
    into :rename2  separated by ' '&lt;BR /&gt;
    from names2&lt;BR /&gt;
   where lowcase(name) ne "key_column_name"&lt;BR /&gt;
        ;&lt;BR /&gt;
quit;[/pre]&lt;BR /&gt;
That prepares the rename information without you having to name any columns, except logical exclusions from renaming, like the key fields.&lt;BR /&gt;
Use this rename information in your merge step, like[pre]&lt;BR /&gt;
data merged_data ;&lt;BR /&gt;
   merge your.dataset1( rename= (&amp;amp;rename1)) &lt;BR /&gt;
         your.dataset2( rename= (&amp;amp;rename2)) ;&lt;BR /&gt;
     by key_column_name ;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
So, is there some real reason to use arrays and avoid the rename processing ?&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Mon, 07 Jan 2008 14:43:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/How-can-i-prefix-the-variable/m-p/6181#M2469</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-01-07T14:43:02Z</dc:date>
    </item>
  </channel>
</rss>

