<?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: Appending value to end of multiple variable names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13633#M1618</link>
    <description>Daniel, &lt;BR /&gt;
&lt;BR /&gt;
That worked like a charm! Once I used that...I simply had to rename the variables like this...&lt;BR /&gt;
&lt;BR /&gt;
PROC DATASETS;              &lt;BR /&gt;
   MODIFY WORK.INFFILE;         &lt;BR /&gt;
                            &lt;BR /&gt;
   RENAME VAR1 = &amp;amp;VAR1_NEW; &lt;BR /&gt;
   RENAME VAR2 = &amp;amp;VAR2_NEW; &lt;BR /&gt;
   RENAME VAR3 = &amp;amp;VAR3_NEW; &lt;BR /&gt;
                            &lt;BR /&gt;
RUN;</description>
    <pubDate>Wed, 01 Apr 2009 16:56:24 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-04-01T16:56:24Z</dc:date>
    <item>
      <title>Appending value to end of multiple variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13629#M1614</link>
      <description>I have created a job that will compare each variable between two different files (of the same format). &lt;BR /&gt;
&lt;BR /&gt;
My problem right now is that I need to identify which file the data came from so that others looking at the reports can make sense of it. For instance, &lt;BR /&gt;
&lt;BR /&gt;
File has the following fields:&lt;BR /&gt;
INTN&lt;BR /&gt;
FIRST&lt;BR /&gt;
LAST&lt;BR /&gt;
BIRTH_DT&lt;BR /&gt;
&lt;BR /&gt;
I was thinking a simple way to distinguish where the value came from would be to have them called:&lt;BR /&gt;
INTN_NEW    or INTN_OLD&lt;BR /&gt;
FIRST_NEW  or INTN_OLD&lt;BR /&gt;
LAST_NEW    or LAST_OLD&lt;BR /&gt;
BIRTH_DT_NEW  or BIRTH_DT_OLD. &lt;BR /&gt;
&lt;BR /&gt;
The variable names will change, depending on the files being read in so I can not hard code the variables and their new names. I was thinking a macro might work but then realized that it isn't really a repetitive action since I would be renaming all of the variables for every row at once. I have no idea where to start. &lt;BR /&gt;
&lt;BR /&gt;
I tried searching these forums for past posts that might help (searched for RENAME, RENAMING, APPEND, ALTER VAR, and none of them had posts which really helped point me in a solid direction).</description>
      <pubDate>Tue, 31 Mar 2009 20:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13629#M1614</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-31T20:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: Appending value to end of multiple variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13630#M1615</link>
      <description>I guess that you could use some macro programing by using information from DICTIONARY.COLUMNS so you could make your code dynamic. Have a look at proc sql select :into clause, and then use the result with rename data set option.&lt;BR /&gt;
&lt;BR /&gt;
Good luck!&lt;BR /&gt;
&lt;BR /&gt;
Linus</description>
      <pubDate>Wed, 01 Apr 2009 06:51:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13630#M1615</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-04-01T06:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Appending value to end of multiple variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13631#M1616</link>
      <description>Hi.&lt;BR /&gt;
&lt;BR /&gt;
Yes, DICTIONARY.COLUMNS or PROC CONTENTS with output to a dataset.&lt;BR /&gt;
&lt;BR /&gt;
Next, you just need to load some macro variables with the input of the DICTIONARY.COLUMS/output from PROC CONTENTS and sufix them with _NEW / _OLD.&lt;BR /&gt;
&lt;BR /&gt;
For examples:&lt;BR /&gt;
&lt;BR /&gt;
proc contents data = WORK.INFILE out = WORK._CONTENTS noprint;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
* cats is just use for text trimming;&lt;BR /&gt;
data _null_;&lt;BR /&gt;
set WORK._CONTENTS end = _EOF; /* _EOF = 1 when end of file */&lt;BR /&gt;
&lt;BR /&gt;
/* create VARX_NEW and VARX_OLD macro vars */&lt;BR /&gt;
/* _N_ is the current observation number, NAME is the variable name */&lt;BR /&gt;
call symput(cats('VAR',put(_N_,best.),'_NEW'),cats(NAME,'_NEW'));&lt;BR /&gt;
call symput(cats('VAR',put(_N_,best.),'_OLD'),cats(NAME,'_OLD'));&lt;BR /&gt;
&lt;BR /&gt;
/* if end of file store VAR_COUNT as total number of variables */&lt;BR /&gt;
if _EOF then call symput('VAR_COUNT',cats(put(_N_,best.)));&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
then you will be able to use in your code:&lt;BR /&gt;
&lt;BR /&gt;
&amp;amp;VAR1_NEW&lt;BR /&gt;
&amp;amp;VAR1_OLD&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
being &amp;amp;VAR_COUNT the total variable count.&lt;BR /&gt;
&lt;BR /&gt;
Hope it helps.&lt;BR /&gt;
&lt;BR /&gt;
Greetings from Portugal.&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos at &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Wed, 01 Apr 2009 08:30:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13631#M1616</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2009-04-01T08:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Appending value to end of multiple variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13632#M1617</link>
      <description>&amp;gt; I have created a job that will compare each variable&lt;BR /&gt;
&amp;gt; between two different files (of the same format). &lt;BR /&gt;
&lt;BR /&gt;
That sounds like PROC COMPARE. No need to fiddle changing anything.&lt;BR /&gt;
&lt;BR /&gt;
If you only want to COMPARE variable names, attributes, and location use OBS=0;</description>
      <pubDate>Wed, 01 Apr 2009 11:00:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13632#M1617</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-04-01T11:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Appending value to end of multiple variable names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13633#M1618</link>
      <description>Daniel, &lt;BR /&gt;
&lt;BR /&gt;
That worked like a charm! Once I used that...I simply had to rename the variables like this...&lt;BR /&gt;
&lt;BR /&gt;
PROC DATASETS;              &lt;BR /&gt;
   MODIFY WORK.INFFILE;         &lt;BR /&gt;
                            &lt;BR /&gt;
   RENAME VAR1 = &amp;amp;VAR1_NEW; &lt;BR /&gt;
   RENAME VAR2 = &amp;amp;VAR2_NEW; &lt;BR /&gt;
   RENAME VAR3 = &amp;amp;VAR3_NEW; &lt;BR /&gt;
                            &lt;BR /&gt;
RUN;</description>
      <pubDate>Wed, 01 Apr 2009 16:56:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Appending-value-to-end-of-multiple-variable-names/m-p/13633#M1618</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-01T16:56:24Z</dc:date>
    </item>
  </channel>
</rss>

