<?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: modifying variables in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88834#M8326</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For Task1, you can simply use the format &lt;STRONG&gt;z7.&lt;/STRONG&gt;, this will place a 0 before the values. Please check the code below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input store_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format store_id z7.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;123456&lt;/P&gt;&lt;P&gt;780123&lt;/P&gt;&lt;P&gt;123560&lt;/P&gt;&lt;P&gt;010203&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for task2, please check the below code where i renamed store_id to id&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro rename(new);&lt;/P&gt;&lt;P&gt;data want(rename=(store_id=&amp;amp;new));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%rename(id);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Sep 2013 02:30:50 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2013-09-20T02:30:50Z</dc:date>
    <item>
      <title>modifying variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88832#M8324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi guys, i need some help on &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;modifying value for the variable&lt;/STRONG&gt;&lt;/SPAN&gt; and &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;changing variable name&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have variable 'store_id' and it has 3000 observations. values are 6 digit numerical only and i want to add 0 (zero)&lt;/P&gt;&lt;P&gt;infront of the all value, how can i do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is what i have&lt;/P&gt;&lt;P&gt;store_id&lt;/P&gt;&lt;P&gt;123456&lt;/P&gt;&lt;P&gt;780123&lt;/P&gt;&lt;P&gt;123560&lt;/P&gt;&lt;P&gt;010203&lt;/P&gt;&lt;P&gt;...........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and this is what i want&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;store_id&lt;/P&gt;&lt;P&gt;0123456&lt;/P&gt;&lt;P&gt;0780123&lt;/P&gt;&lt;P&gt;0123560&lt;/P&gt;&lt;P&gt;0010203&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;task-2&lt;/P&gt;&lt;P&gt;--------&lt;/P&gt;&lt;P&gt;i have variable name &lt;STRONG&gt;'customer_name'&lt;/STRONG&gt; variable and i want to change it with &lt;STRONG&gt;'customer_id'&lt;/STRONG&gt;, i know i can use rename statement but what if i want to use macro like customer_name=&amp;amp;customer_id. ----------how can i use macro...?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please advise - Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 00:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88832#M8324</guid>
      <dc:creator>woo</dc:creator>
      <dc:date>2013-09-20T00:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: modifying variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88833#M8325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. I assume the variable is 6 byte character. You will need to create a new variable to make it 7 character. Here's an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;length store_id $6;&lt;/P&gt;&lt;P&gt;input store_id;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;123456&lt;/P&gt;&lt;P&gt;780123&lt;/P&gt;&lt;P&gt;123560&lt;/P&gt;&lt;P&gt;010203&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have(rename=(store_id=in_store_id));&lt;/P&gt;&lt;P&gt;length store_id $7;&lt;/P&gt;&lt;P&gt;store_id = '0' || in_store_id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. This is a little unclear...can you expand?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 02:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88833#M8325</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2013-09-20T02:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: modifying variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88834#M8326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For Task1, you can simply use the format &lt;STRONG&gt;z7.&lt;/STRONG&gt;, this will place a 0 before the values. Please check the code below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; input store_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format store_id z7.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;123456&lt;/P&gt;&lt;P&gt;780123&lt;/P&gt;&lt;P&gt;123560&lt;/P&gt;&lt;P&gt;010203&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for task2, please check the below code where i renamed store_id to id&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro rename(new);&lt;/P&gt;&lt;P&gt;data want(rename=(store_id=&amp;amp;new));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%rename(id);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 02:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88834#M8326</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2013-09-20T02:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: modifying variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88835#M8327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;for Task 1, Z. format works to add leading 0s&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For task 2, can you please add more details?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 05:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88835#M8327</guid>
      <dc:creator>Amarnath7</dc:creator>
      <dc:date>2013-09-20T05:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: modifying variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88836#M8328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I got answer for first task, i like both approch...Thanks a LOT!&lt;/P&gt;&lt;P&gt;task 2&lt;/P&gt;&lt;P&gt;--------&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;&lt;EM&gt;i have variable name &lt;/EM&gt;'customer_name' variable and i want to change it with 'customer_id', i know i can use rename statement but what if i want to use macro like customer_name=&amp;amp;customer_id. ----------how can i use macro...?&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;basically i have so many variable name and we are planning to modify each and every variables to something else, lets say standard business variable name, so,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;i have variable like below&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;id&lt;/P&gt;&lt;P&gt;store_id&lt;/P&gt;&lt;P&gt;store_add&lt;/P&gt;&lt;P&gt;customer_name&lt;/P&gt;&lt;P&gt;customer_add&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;and i want&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;std_id&lt;/P&gt;&lt;P&gt;std_store_id&lt;/P&gt;&lt;P&gt;std_store_id&lt;/P&gt;&lt;P&gt;std_customer_name&lt;/P&gt;&lt;P&gt;std_customer_add&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what is the best way to achive this insted of using rename statement, i want to use macro somehow...is that something looks feasible or still i am asking something inappropriate....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 16:57:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88836#M8328</guid>
      <dc:creator>woo</dc:creator>
      <dc:date>2013-09-20T16:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: modifying variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88837#M8329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Regarding your 2nd question, there are many approaches that could be used. Here is one approach that could be adapted to work for you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/26/009.html"&gt;http://support.sas.com/kb/26/009.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 18:03:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88837#M8329</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2013-09-20T18:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: modifying variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88838#M8330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let's assume that you have a list of names and you want to get the list of OLD=NEW pairs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro rename(list,prefix);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%local i name ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%do i=1 %to %sysfunc(countw(&amp;amp;list)) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %let name = %scan(&amp;amp;list,&amp;amp;i) ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; &amp;amp;name = &amp;amp;prefix.&amp;amp;name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend rename;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you could use this macro inside of a rename statement.&amp;nbsp; In a datastep for example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; set have ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; rename %rename(id store_id store_add, std_) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Sep 2013 20:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/modifying-variables/m-p/88838#M8330</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-09-20T20:45:47Z</dc:date>
    </item>
  </channel>
</rss>

