<?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 Array for redefining variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Array-for-redefining-variables/m-p/402190#M66825</link>
    <description>&lt;P&gt;I have these variables:&amp;nbsp;Q20_1_1 Q20_1_2 Q20_1_3 Q20_1_4 Q20_1_5 Q36_1_1 Q36_1_2 Q36_1_3 Q36_1_4 Q36_1_5&lt;/P&gt;&lt;P&gt;that need to be redefined as, for an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if Q20_1_1="Never" then Q20_1_1a="Never";&lt;BR /&gt;if Q20_1_1="Once in past 12 months" then Q20_1_1a="Rarely";&lt;BR /&gt;if Q20_1_1="Two to five times in past 12 months" then Q20_1_1a="Sometimes";&lt;BR /&gt;if Q20_1_1="Every other month to monthly" then Q20_1_1a="Often";&lt;BR /&gt;if Q20_1_1="A few times a month to weekly" or Q20_1_1="A few times a week to daily" then Q20_1_1a="Very often";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I create an array for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 08 Oct 2017 15:41:26 GMT</pubDate>
    <dc:creator>lboyd</dc:creator>
    <dc:date>2017-10-08T15:41:26Z</dc:date>
    <item>
      <title>Array for redefining variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-for-redefining-variables/m-p/402190#M66825</link>
      <description>&lt;P&gt;I have these variables:&amp;nbsp;Q20_1_1 Q20_1_2 Q20_1_3 Q20_1_4 Q20_1_5 Q36_1_1 Q36_1_2 Q36_1_3 Q36_1_4 Q36_1_5&lt;/P&gt;&lt;P&gt;that need to be redefined as, for an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if Q20_1_1="Never" then Q20_1_1a="Never";&lt;BR /&gt;if Q20_1_1="Once in past 12 months" then Q20_1_1a="Rarely";&lt;BR /&gt;if Q20_1_1="Two to five times in past 12 months" then Q20_1_1a="Sometimes";&lt;BR /&gt;if Q20_1_1="Every other month to monthly" then Q20_1_1a="Often";&lt;BR /&gt;if Q20_1_1="A few times a month to weekly" or Q20_1_1="A few times a week to daily" then Q20_1_1a="Very often";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I create an array for this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Oct 2017 15:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-for-redefining-variables/m-p/402190#M66825</guid>
      <dc:creator>lboyd</dc:creator>
      <dc:date>2017-10-08T15:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Array for redefining variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-for-redefining-variables/m-p/402198#M66826</link>
      <description>&lt;P&gt;Sounds more like you want a format. Then you could probably avoid creating new variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
  value $freqa 
  "Never"="Never"
  "Once in past 12 months"="Rarely"
  "Two to five times in past 12 months"="Sometimes"
  "Every other month to monthly"="Often"
  "A few times a month to weekly"
 ,"A few times a week to daily"="Very often"
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you could just attach that format to your existing variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have ;
  tables  Q20_1_1 Q20_1_2 Q20_1_3 Q20_1_4 Q20_1_5 Q36_1_1 Q36_1_2 Q36_1_3 Q36_1_4 Q36_1_5 ;
  format  Q20_1_1 Q20_1_2 Q20_1_3 Q20_1_4 Q20_1_5 Q36_1_1 Q36_1_2 Q36_1_3 Q36_1_4 Q36_1_5 $freqa. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you really did need to make new variables then you two arrays. One for the original and one for the new variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  array in Q20_1_1 Q20_1_2 Q20_1_3 Q20_1_4 Q20_1_5 Q36_1_1 Q36_1_2 Q36_1_3 Q36_1_4 Q36_1_5 ;
  array out $20 Q20_1_1a Q20_1_2a Q20_1_3a Q20_1_4a Q20_1_5a Q36_1_1a Q36_1_2a Q36_1_3a Q36_1_4a Q36_1_5a ;
  do i=1 to dim(in);
    out(i)=put(in(i),$freqa.);
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Oct 2017 17:24:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-for-redefining-variables/m-p/402198#M66826</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-08T17:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Array for redefining variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-for-redefining-variables/m-p/402203#M66827</link>
      <description>Thank you-that worked!!</description>
      <pubDate>Sun, 08 Oct 2017 18:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-for-redefining-variables/m-p/402203#M66827</guid>
      <dc:creator>lboyd</dc:creator>
      <dc:date>2017-10-08T18:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Array for redefining variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Array-for-redefining-variables/m-p/402482#M66844</link>
      <description>&lt;P&gt;Then mark it as a solution.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 19:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Array-for-redefining-variables/m-p/402482#M66844</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-09T19:18:04Z</dc:date>
    </item>
  </channel>
</rss>

