<?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 replacing value using array or macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348825#M80822</link>
    <description>&lt;P&gt;&lt;BR /&gt;Hi, I would like to replace values in C and D with value from B. Can anyone help to create code using array or macro ? Thank you so much !&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input A $ B C $	D ;
datalines;
CA	1	1	1
CA	2	B	1
CA	3	B	9
CA	4	B	8
CA	6	R	2
NV	1	B	1
NV	2	B	1
NV	3	B	1
NV	4	B	1
NV	5	B	1
NV	6	B	1
NV	1	R	4
NV	2	R	6
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 10 Apr 2017 18:28:01 GMT</pubDate>
    <dc:creator>octrout</dc:creator>
    <dc:date>2017-04-10T18:28:01Z</dc:date>
    <item>
      <title>replacing value using array or macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348825#M80822</link>
      <description>&lt;P&gt;&lt;BR /&gt;Hi, I would like to replace values in C and D with value from B. Can anyone help to create code using array or macro ? Thank you so much !&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input A $ B C $	D ;
datalines;
CA	1	1	1
CA	2	B	1
CA	3	B	9
CA	4	B	8
CA	6	R	2
NV	1	B	1
NV	2	B	1
NV	3	B	1
NV	4	B	1
NV	5	B	1
NV	6	B	1
NV	1	R	4
NV	2	R	6
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 18:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348825#M80822</guid>
      <dc:creator>octrout</dc:creator>
      <dc:date>2017-04-10T18:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: replacing value using array or macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348828#M80824</link>
      <description>&lt;P&gt;Neither macro nor arrays are needed.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
c = put(b,best.);
d = b;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Apr 2017 18:40:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348828#M80824</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-04-10T18:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: replacing value using array or macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348831#M80826</link>
      <description>Thanks for the reply. What if i have many variables to replace values ?</description>
      <pubDate>Mon, 10 Apr 2017 18:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348831#M80826</guid>
      <dc:creator>octrout</dc:creator>
      <dc:date>2017-04-10T18:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: replacing value using array or macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348854#M80833</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37980"&gt;@octrout&lt;/a&gt; wrote:&lt;BR /&gt;Thanks for the reply. What if i have many variables to replace values ?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Provide a more complete example. It is likely to be a variation on what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;has already provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro is likely not the way to go though a number of arrays may be needed depending on your rules for which values are used to assign to other variables.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 19:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348854#M80833</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-10T19:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: replacing value using array or macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348856#M80834</link>
      <description>&lt;P&gt;Then you need to clarify your logic. You can create an array to loop through multiple variables if needed but given what you've posted there's no need for such a solution.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 19:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348856#M80834</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-10T19:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: replacing value using array or macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348860#M80836</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have about 60 variables that need to replace with values from one variable.&lt;/P&gt;&lt;P&gt;This would be an example data set need to replace c,d,e,f,g with values from B. &amp;nbsp;Thanks !&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input A $ B C $	D E F G ;
datalines;
CA	1	1	1 20 7 10
CA	2	B	1 2 5 18
CA	3	B	9 3 5 18
CA	4	B	8 3 3 7
CA	6	R	2 4 2 6
NV	1	B	1 4 1 9
NV	2	B	1 4 1 10
NV	3	B	1 5 7 18
NV	4	B	1 5 4 8
NV	5	B	1 5 4 7
NV	6	B	1 5 6 8
NV	1	R	4 5 7 9
NV	2	R	6 5 8 10
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 20:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348860#M80836</guid>
      <dc:creator>octrout</dc:creator>
      <dc:date>2017-04-10T20:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: replacing value using array or macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348862#M80838</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/37980"&gt;@octrout&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have about 60 variables that need to replace with values from one variable.&lt;/P&gt;
&lt;P&gt;This would be an example data set need to replace c,d,e,f,g with values from B. &amp;nbsp;Thanks !&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input A $ B C $	D E F G ;
datalines;
CA	1	1	1 20 7 10
CA	2	B	1 2 5 18
CA	3	B	9 3 5 18
CA	4	B	8 3 3 7
CA	6	R	2 4 2 6
NV	1	B	1 4 1 9
NV	2	B	1 4 1 10
NV	3	B	1 5 7 18
NV	4	B	1 5 4 8
NV	5	B	1 5 4 7
NV	6	B	1 5 6 8
NV	1	R	4 5 7 9
NV	2	R	6 5 8 10
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Declare one array for character and another for numeric variables. Then use my assignments in do loops for 1 to dim(array), one for the numeric and one for the character array.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2017 20:06:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/replacing-value-using-array-or-macro/m-p/348862#M80838</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-04-10T20:06:33Z</dc:date>
    </item>
  </channel>
</rss>

