<?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: Most efficient way to recode large number of variables in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/261126#M7174</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/79711"&gt;@simkinm2&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a data set with over 400 variables that I need to recode. &amp;nbsp;The data looks something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Var_A = values from 1-44&lt;/P&gt;
&lt;P&gt;Var_B = Values from 45-98&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a new variable by adding a specific value to each old&amp;nbsp;variable, for example New_Var_A = Var_A +44. &amp;nbsp;Rather than creating over 400 if then statements, is there a more efficient way to recode these new variables with the new values? &amp;nbsp;I attempted to write a code like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data new;&lt;/P&gt;
&lt;P&gt;set old;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;New_Var_A = Var_A +44;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;New_Var_B = Var_B + 98;&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;STRONG&gt;but the new variables are not addiing up to the proper &amp;nbsp;values. &amp;nbsp;Any suggestions are greatly appreciated!&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What are the values of the variables in the Old data set? What are the actual values in the New data set. It would help to provide an example Old data set, in the form of data step code; Your full code for those variables generating values "&lt;STRONG&gt;not addiing up to the proper &amp;nbsp;values&lt;/STRONG&gt;"; and the actual&amp;nbsp;desired output. A sample of 5 variable and five or ten rows of data should be sufficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW if the values of your shown VarA and VarB actually are that way and you request to increment by 44 makes be think that you may inserting a value at the beginning of some sort of list and just shifing a bunch of possitions into the next one. If so, the whole process maybe requires some consideration.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Apr 2016 16:53:38 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2016-04-04T16:53:38Z</dc:date>
    <item>
      <title>Most efficient way to recode large number of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/260964#M7164</link>
      <description>&lt;P&gt;I have a data set with over 400 variables that I need to recode. &amp;nbsp;The data looks something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var_A = values from 1-44&lt;/P&gt;&lt;P&gt;Var_B = Values from 45-98&lt;/P&gt;&lt;P&gt;etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to create a new variable by adding a specific value to each old&amp;nbsp;variable, for example New_Var_A = Var_A +44. &amp;nbsp;Rather than creating over 400 if then statements, is there a more efficient way to recode these new variables with the new values? &amp;nbsp;I attempted to write a code like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;set old;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;New_Var_A = Var_A +44;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;New_Var_B = Var_B + 98;&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;but the new variables are not addiing up to the proper &amp;nbsp;values. &amp;nbsp;Any suggestions are greatly appreciated!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Apr 2016 22:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/260964#M7164</guid>
      <dc:creator>simkinm2</dc:creator>
      <dc:date>2016-04-03T22:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: Most efficient way to recode large number of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/260970#M7165</link>
      <description>&lt;P&gt;You can use an ARRAY to make the coding easier, but the end result will be the same. &amp;nbsp;So I am not sure what your issue is with the values not being created properly. &amp;nbsp;Just create arrays for the variable pairs with 44 different and separate set of arrays for the 98 different pairs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  array old1 VARA VARC ... ;
  array new1 new_VARA new_VARC ... ;
  array old2 VARB VARD ... ;
  array new2 new_VARB new_VARD ... ;
  do i=1 to dim(old1) ;
      new1(i) = old1(i) + 44 ;
  end;
  do i=1 to dim(old2);
      new2(i) = old2(i) + 98 ;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Apr 2016 00:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/260970#M7165</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-04-04T00:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Most efficient way to recode large number of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/261003#M7167</link>
      <description>&lt;P&gt;Your problem is mainly die to that fact that you have 400 variables. That's not a convenient way to store, and maintain data.&lt;/P&gt;
&lt;P&gt;Transpose it to Long, and your data management&amp;nbsp;will be much easier.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 07:56:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/261003#M7167</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-04-04T07:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: Most efficient way to recode large number of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/261126#M7174</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/79711"&gt;@simkinm2&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have a data set with over 400 variables that I need to recode. &amp;nbsp;The data looks something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Var_A = values from 1-44&lt;/P&gt;
&lt;P&gt;Var_B = Values from 45-98&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a new variable by adding a specific value to each old&amp;nbsp;variable, for example New_Var_A = Var_A +44. &amp;nbsp;Rather than creating over 400 if then statements, is there a more efficient way to recode these new variables with the new values? &amp;nbsp;I attempted to write a code like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data new;&lt;/P&gt;
&lt;P&gt;set old;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;New_Var_A = Var_A +44;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;New_Var_B = Var_B + 98;&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;STRONG&gt;but the new variables are not addiing up to the proper &amp;nbsp;values. &amp;nbsp;Any suggestions are greatly appreciated!&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What are the values of the variables in the Old data set? What are the actual values in the New data set. It would help to provide an example Old data set, in the form of data step code; Your full code for those variables generating values "&lt;STRONG&gt;not addiing up to the proper &amp;nbsp;values&lt;/STRONG&gt;"; and the actual&amp;nbsp;desired output. A sample of 5 variable and five or ten rows of data should be sufficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW if the values of your shown VarA and VarB actually are that way and you request to increment by 44 makes be think that you may inserting a value at the beginning of some sort of list and just shifing a bunch of possitions into the next one. If so, the whole process maybe requires some consideration.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 16:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/261126#M7174</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-04T16:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Most efficient way to recode large number of variables</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/261196#M7175</link>
      <description>&lt;P&gt;Thanks for all your responses. &amp;nbsp;I realized that the issue was actually in vlookup table I had imported, which had some incorrect values.. My first step of adding a value to the old variable worked after all.&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;</description>
      <pubDate>Mon, 04 Apr 2016 18:48:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Most-efficient-way-to-recode-large-number-of-variables/m-p/261196#M7175</guid>
      <dc:creator>simkinm2</dc:creator>
      <dc:date>2016-04-04T18:48:24Z</dc:date>
    </item>
  </channel>
</rss>

