<?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: Recoding multiple variables at the same time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Recoding-multiple-variables-at-the-same-time/m-p/313847#M68262</link>
    <description>&lt;P&gt;SAS contains a standard tool for processing a group of variables in the same way.&amp;nbsp; Arrays do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;array vars {4} a b c d;&lt;/P&gt;
&lt;P&gt;do _n_=1 to 4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if vars{_n_}=1 then vars{_n_}=10;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll need to type all your IF/THEN statements once.&amp;nbsp; Then the DO loop changes one variable at a time, applying all the logic between DO and END.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Nov 2016 17:46:33 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-11-23T17:46:33Z</dc:date>
    <item>
      <title>Recoding multiple variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-multiple-variables-at-the-same-time/m-p/313841#M68261</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to recode a bunch of variables at the same time. For e.g. I have the following variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) A&lt;/P&gt;&lt;P&gt;2) B&lt;/P&gt;&lt;P&gt;3) C&lt;/P&gt;&lt;P&gt;4) D&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;They all take values from 1 through 9. I want to recode the values for all these variables in the same manner.&lt;/P&gt;&lt;P&gt;E.g. if A = 1 then A = 10. The same rule applies to all the variables (A-D). Is there a way to do this using a macro or a loop? I don't want to give if-then commands individually for each of the 4 variables and am looking for a more efficient way to do this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 16:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-multiple-variables-at-the-same-time/m-p/313841#M68261</guid>
      <dc:creator>KarD</dc:creator>
      <dc:date>2016-11-23T16:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Recoding multiple variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Recoding-multiple-variables-at-the-same-time/m-p/313847#M68262</link>
      <description>&lt;P&gt;SAS contains a standard tool for processing a group of variables in the same way.&amp;nbsp; Arrays do that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;array vars {4} a b c d;&lt;/P&gt;
&lt;P&gt;do _n_=1 to 4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if vars{_n_}=1 then vars{_n_}=10;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You'll need to type all your IF/THEN statements once.&amp;nbsp; Then the DO loop changes one variable at a time, applying all the logic between DO and END.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2016 17:46:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Recoding-multiple-variables-at-the-same-time/m-p/313847#M68262</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-11-23T17:46:33Z</dc:date>
    </item>
  </channel>
</rss>

