<?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: changing the values of a large number of variables at the same time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244140#M45465</link>
    <description>&lt;P&gt;If your variables names appear sequentially in the dataset variable list then their names and order doesn't matter. The firstOne--lastOne list will include all variables in between those two, as long as they are of the same type (numeric or character).&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jan 2016 04:06:44 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-01-18T04:06:44Z</dc:date>
    <item>
      <title>changing the values of a large number of variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244115#M45456</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a dataset with a bunch of variables: a1-a20 (i.e. a1, a2, ... a20), b1-b10, c1-c10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All of the variables have the same attributes (all numeric): 1 = yes, 2 = no, 3 = don't know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a quick way to change all the variables, such that whenever the value is 3, it is set to missing, for all variables in the dataset?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;the dataset looks like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a1 a2 a3... b1&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; 2 &amp;nbsp; 1 &amp;nbsp;...3&lt;/P&gt;
&lt;P&gt;etc.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 00:47:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244115#M45456</guid>
      <dc:creator>howdelicious</dc:creator>
      <dc:date>2016-01-18T00:47:12Z</dc:date>
    </item>
    <item>
      <title>Re: changing the values of a large number of variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244116#M45457</link>
      <description>&lt;P&gt;I'm not 100% sure what you're after, but you'll most likely be looking for an array, call missing() routine and whichn().&lt;BR /&gt;&lt;BR /&gt;Something like this if I understand your requirements.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;array letters(*) a1-a10 b1-b10 c1-c10;

if whichn(3, of letters(*))&amp;gt;0 then call missing (of letters(*));&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Jan 2016 00:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244116#M45457</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-18T00:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: changing the values of a large number of variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244117#M45458</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;
&lt;P&gt;Thanks for your reply. I am thinking of an array to change the values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Essentially, I have several hundred numeric variables,&amp;nbsp;where&amp;nbsp;1 = yes, 2 = no, 3 = don't know.&lt;/P&gt;
&lt;P&gt;I wish to change all the '3's to missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are some examples of variable names that I have:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;a1_1-a1_8&lt;BR /&gt;b1_1-b1_9&lt;BR /&gt;b1n2_1-b1n2_7&lt;BR /&gt;c1n3_1-c1n3_9&lt;BR /&gt;d1-d10&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The issue&amp;nbsp;&lt;/STRONG&gt;is that when I tried using an array, it wouldn't read in the variables "&lt;SPAN&gt;a1_1-a1_8". It comes up with an error saying:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;Syntax error, expecting one of the following: an integer constant, *.&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 00:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244117#M45458</guid>
      <dc:creator>howdelicious</dc:creator>
      <dc:date>2016-01-18T00:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: changing the values of a large number of variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244124#M45461</link>
      <description>&lt;P&gt;Your variable names cannot form numbered variable lists but you can simply use&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array letters{*} a1_1 -- d10;
do i = 1 to dim(letters);
	if letters{i} = 3 then call missing(letters{i});
	end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;where a1_1 and d10 are respectively the first and last of your three-valued variables.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 02:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244124#M45461</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-01-18T02:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: changing the values of a large number of variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244134#M45462</link>
      <description>&lt;P&gt;*EDIT*&lt;/P&gt;
&lt;P&gt;Actually, I coded in the array incorrectly before. Your solution worked perfectly. Thank you!!!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 04:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244134#M45462</guid>
      <dc:creator>howdelicious</dc:creator>
      <dc:date>2016-01-18T04:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: changing the values of a large number of variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244136#M45463</link>
      <description>&lt;P&gt;Do you have any naming convention? If you don't, unfortunately the only way is to manually write them out.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 03:30:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244136#M45463</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-18T03:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: changing the values of a large number of variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244140#M45465</link>
      <description>&lt;P&gt;If your variables names appear sequentially in the dataset variable list then their names and order doesn't matter. The firstOne--lastOne list will include all variables in between those two, as long as they are of the same type (numeric or character).&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 04:06:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244140#M45465</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-01-18T04:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: changing the values of a large number of variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244141#M45466</link>
      <description>&lt;P&gt;And if you want to explicitly specify numeric only&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;firstvar-numeric-lastvar&lt;/PRE&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#p0wphcpsfgx6o7n1sjtqzizp1n39.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/68089/HTML/default/viewer.htm#p0wphcpsfgx6o7n1sjtqzizp1n39.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2016 04:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244141#M45466</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-18T04:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: changing the values of a large number of variables at the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244142#M45467</link>
      <description>Hi Reeza and PGStats, the thread has been solved thanks to PGStat's original post. &lt;BR /&gt;&lt;BR /&gt;I mis-coded my array earlier, hence it didn't work. I realised my error and found that PGStat's solution worked perfectly. Thanks for your help!!</description>
      <pubDate>Mon, 18 Jan 2016 04:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/changing-the-values-of-a-large-number-of-variables-at-the-same/m-p/244142#M45467</guid>
      <dc:creator>howdelicious</dc:creator>
      <dc:date>2016-01-18T04:15:25Z</dc:date>
    </item>
  </channel>
</rss>

