<?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: Rename variables with the same suffix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305754#M65254</link>
    <description>seems I have to give 200 variable names in the list when I call ren? Is any way that we can create the list automatically?</description>
    <pubDate>Wed, 19 Oct 2016 19:57:02 GMT</pubDate>
    <dc:creator>jackblack</dc:creator>
    <dc:date>2016-10-19T19:57:02Z</dc:date>
    <item>
      <title>Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305737#M65245</link>
      <description>&lt;P&gt;I have monhtly datasets, say data1601 to data1612.&amp;nbsp; Variables in these datasets have a same suffix&amp;nbsp; of the month.&amp;nbsp; For example, variables in data1601 will have a suffix of 1601 and data1612 will have a suffix of 1612, such as&amp;nbsp;hight1601, weight1601, income1601...&lt;/P&gt;&lt;P&gt;I want to drop 1601,1602 and 1612 so that I can put 12 month data in to one dataset and have these names:&lt;/P&gt;&lt;P&gt;hight, weight, income...&amp;nbsp; How can I do that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="mailto:jackblack1688@gmail.com" target="_blank"&gt;jackblack1688@gmail.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 19:12:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305737#M65245</guid>
      <dc:creator>jackblack</dc:creator>
      <dc:date>2016-10-19T19:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305747#M65247</link>
      <description>&lt;P&gt;Do the monthly data sets have a variable inside that would identify the appropriate month?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How many variables are involved? A solution that may work for two or three could be too cumbersome for 50 or 60.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you have any say in the manner it is a better idea in the long run to have variables with the same characteristics and meaning to have the same name. Then add additional fields to hold the descriptive data such as month, sales, location and such.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 19:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305747#M65247</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-19T19:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305750#M65250</link>
      <description>it has 200 variables.&lt;BR /&gt;Do the monthly data sets have a variable inside that would identify the appropriate month? YES</description>
      <pubDate>Wed, 19 Oct 2016 19:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305750#M65250</guid>
      <dc:creator>jackblack</dc:creator>
      <dc:date>2016-10-19T19:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305752#M65252</link>
      <description>&lt;P&gt;You can create a macro program&amp;nbsp;to create a RENAME statment supplying list of prefixes only:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro ren(prefixes=&lt;SPAN&gt;, &amp;nbsp;mon=);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;%global ren;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;%let nvars = %sysfunc( countw("&amp;amp;prefixes"));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;%let ren = ;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %do i=1 %to &amp;amp;nvars;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %let pfx =&amp;nbsp;%scan(&amp;amp;prefixses, &amp;amp;i);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; %let ren = %trim(&amp;amp;ren) &amp;amp;pfx.&amp;amp;mon = &amp;amp;pfx;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%mend ren;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%ren(prefixes=&lt;SPAN&gt;hight weight income ..., &amp;nbsp;mon=1601);&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data want / view=want;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; set have(RENAME=(&amp;amp;ren));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;...your code ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 19:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305752#M65252</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-19T19:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305754#M65254</link>
      <description>seems I have to give 200 variable names in the list when I call ren? Is any way that we can create the list automatically?</description>
      <pubDate>Wed, 19 Oct 2016 19:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305754#M65254</guid>
      <dc:creator>jackblack</dc:creator>
      <dc:date>2016-10-19T19:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305766#M65261</link>
      <description>&lt;P&gt;Do you mean that you have 200 different prefixes ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case there is another way to create the REN macro variable:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let suffix = 1601;&lt;/P&gt;
&lt;P&gt;data _NULL_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;length ren $5000 &amp;nbsp;varname $32 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;dsid = open("have"); &amp;nbsp; /* replace "have" to your input dataset name in a format of lib.dsname */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if dsid then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nvars = attrn(dsid , 'nvars');&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; do i=1 to nvars;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;varname = varname(dsid, i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if &amp;nbsp;index(varname, trim(symget('suffix'))) = length(trim(varname)) - 4 +1 then &amp;nbsp; &amp;nbsp; &amp;nbsp; /* 4 = length of "1601" */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ren = combl(ren || trim(varname) || "&amp;amp;suffix" || ' = ' ||&lt;SPAN&gt; trim(varname) );&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dsid = close(dsid);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; call symput('REN' , ren);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data want / view=want;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; set have(rename=(&amp;amp;ren));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;... your code ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 20:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305766#M65261</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-19T20:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305786#M65271</link>
      <description>&lt;P&gt;what is COMBL?&amp;nbsp; seems I don't know this function.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 20:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305786#M65271</guid>
      <dc:creator>jackblack</dc:creator>
      <dc:date>2016-10-19T20:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305787#M65272</link>
      <description>&lt;P&gt;sorry. it should be &lt;STRONG&gt;COMPBL&lt;/STRONG&gt; (compress with blank);&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 21:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305787#M65272</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-19T21:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305789#M65274</link>
      <description>&lt;P&gt;Thank you so much!&amp;nbsp; I think the logic is good but it is little off the target.&amp;nbsp; This is what I have but I think we can fix it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;%put &amp;amp;ren;&lt;/P&gt;&lt;P&gt;crea16011601 = crea1601 ncwb16011601 = ncwb1601 bbtt16011601 = bbtt1601 aclt16011601 = aclt1601 nchb16011601 = nchb1601 mobo16011601 = mobo1601&lt;/P&gt;&lt;P&gt;mcro16011601 = mcro1601 ncro16011601 = ncro1601 aclh16011601 = aclh1601 ncbu16011601 = ncbu1601 mbdq16011601 = mbdq1601&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 21:04:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305789#M65274</guid>
      <dc:creator>jackblack</dc:creator>
      <dc:date>2016-10-19T21:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305791#M65275</link>
      <description>&lt;P&gt;it works if I modify it to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;ren = compbl(ren || trim(varname) || &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;' = '&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; || substr(varname,&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;,length(varname)-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;crea1601 = crea ncwb1601 = ncwb bbtt1601 = bbtt aclt1601 = aclt nchb1601 = nchb mobo1601 = mobo mcro1601 = mcro ncro1601 = ncro aclh1601 = aclh ncbu1601 = ncbu mbdq1601 = mbdq bart1601 = bart ruti1601 = ruti ...........&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks you soooooooooo much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 21:09:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305791#M65275</guid>
      <dc:creator>jackblack</dc:creator>
      <dc:date>2016-10-19T21:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305794#M65277</link>
      <description>&lt;P&gt;OK, it is my fault.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;change in the loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do i=1 to nvars;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;varname = varname(dsid, i);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt;ix =&amp;nbsp;index(varname, trim(symget('suffix'))) -1;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if &amp;nbsp;ix = length(trim(varname))&lt;STRONG&gt; - 4&lt;/STRONG&gt; &amp;nbsp;then &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ren = combl(ren || trim(varname) || ' = ' ||&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;substr(varname,1,ix)&lt;/STRONG&gt; );&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dsid = close(dsid);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 21:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305794#M65277</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-19T21:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305819#M65294</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/110983"&gt;@jackblack&lt;/a&gt; wrote:&lt;BR /&gt;seems I have to give 200 variable names in the list when I call ren? Is any way that we can create the list automatically?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is a point where I ask how are you getting this data? If you are reading it from an external data source then you should be able to read it into sensible variables without the month information attached to the variable name and have a variable that contains that information. If someone else created the SAS data sets you&amp;nbsp;may want to backtrack and see how those names come about. If there is not a real good reason for that naming, which from this topic sounds not to be the case, then you may be able to head it off earlier in the process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There may also be a question of 200&amp;nbsp;variables in general.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 23:11:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305819#M65294</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-19T23:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305877#M65315</link>
      <description>&lt;P&gt;That sounds like an very bad and time consuming process. &amp;nbsp;Why is the process set up in this way. &amp;nbsp;What does your data transfer agreement say? &amp;nbsp;How are you using the data going forward? &amp;nbsp;I would adivise that the data be manipulated at import time into a usable format, i.e. havinig month information in a column, and a column for each of the paramters, and then all data set together:&lt;/P&gt;
&lt;P&gt;MONTH &amp;nbsp; &amp;nbsp; &amp;nbsp;HEIGHT &amp;nbsp; &amp;nbsp;WEIGHT &amp;nbsp; &amp;nbsp; INCOME&lt;/P&gt;
&lt;P&gt;1016 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This will aid you in any further processing. &amp;nbsp;To further this, is this clinical data, which it appears so from the headings. &amp;nbsp;If so, why are you not using one of the CDIS models for data - SEND, SDTM, ADaM etc. &amp;nbsp;This is industry standard nowadays.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 08:35:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305877#M65315</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-20T08:35:49Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305897#M65321</link>
      <description>&lt;P&gt;Mainly I absolutly agree with the comments given by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw﻿&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only situation, I can think of, to leave the variable names as are, is&lt;/P&gt;
&lt;P&gt;in case of dealing with merged datasets of different months and have a seperate variable per month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even though, having the MONTH as a column in the datasets, instead of - as a part of the variable name -&lt;/P&gt;
&lt;P&gt;enables all analysis and reports with more simple code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 10:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305897#M65321</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-20T10:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305905#M65328</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data1601;
 height1601=1;
 weight1601=1;
 output;
run;
data data1612;
 height1612=2;
 wight1612=2;
 output;
run;
data _null_;
 set sashelp.vcolumn(where=(libname='WORK')) end=last;
 by memname;
 if _n_=1 then call execute('proc datasets library=work nolist nodetails;');
 if first.memname then call execute('modify '||memname||';rename ');
 call execute(name||'='||compress(name,'0123456789'));
 if last.memname then call execute(';');
 if last then call execute('quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Oct 2016 10:47:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305905#M65328</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-20T10:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305934#M65340</link>
      <description>&lt;P&gt;Thank you all for your help.&amp;nbsp; I don't want to say why it was set up in that way but&amp;nbsp;have to&amp;nbsp;read the data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ksharp, if I understand your code correctly it will rename all variables from all datasets in WORK.&amp;nbsp; Can you show me the results?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have 3 years datasets monthly and I may need some of them so I am not sure your first.memname and last.memname will work from the data storage folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I remembered I did a similar job before but I don't have the code anymore because of changing jobs.&amp;nbsp; I think basically we need prco contents to&amp;nbsp;create and output a file that has a statement of&amp;nbsp;rename&amp;nbsp;then using %include in next data steps.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 12:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305934#M65340</guid>
      <dc:creator>jackblack</dc:creator>
      <dc:date>2016-10-20T12:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305936#M65341</link>
      <description>&lt;P&gt;Renaming &lt;STRONG&gt;all&lt;/STRONG&gt; variables by compressing 0-9 digits from their names, needs a check:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;are there variable names where the digits are&lt;STRONG&gt; not the suffix&lt;/STRONG&gt; of yymm format (like 1601) !&lt;/P&gt;
&lt;P&gt;If there are such variables, the code should check for suffix being in a given period (like 1601 - 1612).&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 13:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305936#M65341</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-20T13:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Rename variables with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305937#M65342</link>
      <description>&lt;P&gt;I am sure there are more than one way to do this job but I tried Shmuel's code and it works for me.&amp;nbsp; Thank you all again.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 13:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rename-variables-with-the-same-suffix/m-p/305937#M65342</guid>
      <dc:creator>jackblack</dc:creator>
      <dc:date>2016-10-20T13:16:36Z</dc:date>
    </item>
  </channel>
</rss>

