<?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 Concatenate the name of table with a column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854149#M337571</link>
    <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm wondering if it's possible in SAS to concatenate the name of table with the column.&lt;/P&gt;
&lt;P&gt;I have a table ZC1, I have the column Date in this table, I would like to have the column Date_ZC1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jan 2023 17:05:52 GMT</pubDate>
    <dc:creator>SASdevAnneMarie</dc:creator>
    <dc:date>2023-01-17T17:05:52Z</dc:date>
    <item>
      <title>Concatenate the name of table with a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854149#M337571</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm wondering if it's possible in SAS to concatenate the name of table with the column.&lt;/P&gt;
&lt;P&gt;I have a table ZC1, I have the column Date in this table, I would like to have the column Date_ZC1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 17:05:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854149#M337571</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2023-01-17T17:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate the name of table with a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854160#M337575</link>
      <description>&lt;P&gt;In case you need to re-name more than one variable in the table, this is a solution that works with all columns (variables) in your table. However, if you only need to rename one variable, the DATA step solution works well enough.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data ZC1;
input Date date9. x ;
cards;
01JAN2023 3
;
run;
   %macro rename;
proc sql;
   select distinct name into :var1- 
   from dictionary.columns
   where libname='WORK' and memname='ZC1' ;
   %let NUM_VARS = &amp;amp;sqlobs;
   %let DSN = ZC1;
   quit;
proc datasets library=WORK;
   modify &amp;amp;DSN;
   rename
   %do i = 1 %to &amp;amp;sqlobs;
   &amp;amp;&amp;amp;var&amp;amp;i = %sysfunc(catx(_,&amp;amp;DSN, &amp;amp;&amp;amp;var&amp;amp;i))
   %end;
   ;
   quit;
   run;
%mend;
%rename;&lt;BR /&gt;
data ZC1 (rename=(Date=ZC1_Date)); /*This is a straightforward renaming of just the DATE variable*/
   set ZC1;
   run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jan 2023 17:46:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854160#M337575</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2023-01-17T17:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate the name of table with a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854165#M337577</link>
      <description>&lt;P&gt;Caution: Variable names are limited to 32 characters. SAS data set names are limited to 32 characters. You potentially are asking to create variable names that exceed the 32 character limit for a single variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The question might be &lt;STRONG&gt;why&lt;/STRONG&gt; this is desirable or needed. Are you intending to merge multiple data sets and hence have multiple Date_ZC1 Date_ZC2 Date_ZC3 variables? If so, again there may be a reason to ask why? Such data is cumbersome to work with and often is not needed. If you add a variable that indicates the name of the data set source to such a set that results from appending data then you can use that variable for reporting or typically grouping responses/values for analysis.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 18:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854165#M337577</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-17T18:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate the name of table with a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854172#M337579</link>
      <description>Hello,&lt;BR /&gt;Thank you for your message. I need it for the merging the rates for zc1, zc2, …&lt;BR /&gt;In real life I need to create rate_zc1, rate_zc2 because in the table zc1–zc20 I have only two columns Date and Rate. The column date_zc1 was for exemple. Rate+zcxx are less than 32 characters.</description>
      <pubDate>Tue, 17 Jan 2023 18:24:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854172#M337579</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2023-01-17T18:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate the name of table with a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854173#M337580</link>
      <description>Thank you, I need to rename only one column.</description>
      <pubDate>Tue, 17 Jan 2023 18:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854173#M337580</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2023-01-17T18:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate the name of table with a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854176#M337581</link>
      <description>&lt;P&gt;So you have two columns?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's assume they are and ID variable and the DATE variable you mentioned.&lt;/P&gt;
&lt;P&gt;So first combine the data and keep track of where the data came from.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tall;
  set zc1-zc20 indsname=indsname;
  by id;
  length dsname $32 ;
  dsname=scan(indsname,-1,'.');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now if you want you can use PROC TRANSPOSE to make a WIDE dataset instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=tall out=wide(drop=_name_) prefix=date_;
  by id;
  id dsname;
  var date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jan 2023 18:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854176#M337581</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-01-17T18:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate the name of table with a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854177#M337582</link>
      <description>&lt;P&gt;Do not merge the datasets, stack them (SET with multiple datasets and INDSNAME= option), and keep the dataset name as new column.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 18:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854177#M337582</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-17T18:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate the name of table with a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854217#M337588</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286185"&gt;@SASdevAnneMarie&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello,&lt;BR /&gt;Thank you for your message. I need it for the merging the rates for zc1, zc2, …&lt;BR /&gt;In real life I need to create rate_zc1, rate_zc2 because in the table zc1–zc20 I have only two columns Date and Rate. The column date_zc1 was for exemple. Rate+zcxx are less than 32 characters.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show how you intend to merge the rates and define what sort of rate is involved.&lt;/P&gt;
&lt;P&gt;I have a strong suspicion that if you only have two variables as described, date and rate, that any combination of the existing rates to make some sort of composite rate may be problematic depending on the definitions of the actual "rate" involved. If the rate is something like "miles per gallon" any thing that combines different "rate" values that do not include the individual miles and gallons used to calculate the combined value is likely incorrect.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 22:37:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854217#M337588</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-01-17T22:37:59Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate the name of table with a column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854330#M337630</link>
      <description>&lt;P&gt;Thank you Tom, that works !&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 14:23:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-the-name-of-table-with-a-column/m-p/854330#M337630</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2023-01-18T14:23:56Z</dc:date>
    </item>
  </channel>
</rss>

