<?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: change the values of multiple variables with same prefix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/548893#M152260</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18062"&gt;@gzr2mz39&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have many character variables that begin with "ACT_".&lt;BR /&gt;I need to change blanks (i.e. "") for these variables to "missing".&lt;BR /&gt;Any ideas how to do this?&lt;BR /&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do your current values actually have quote marks in them? If not then your value is already "missing".&lt;/P&gt;
&lt;P&gt;Run this code and look in the log to see if the message is present:&lt;/P&gt;
&lt;PRE&gt;data example;
   length var $ 10;
   var='';
   if missing(var) then put "WARNING: Value of VAR is missing!";
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 05 Apr 2019 19:11:54 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-04-05T19:11:54Z</dc:date>
    <item>
      <title>change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/548867#M152255</link>
      <description>&lt;P&gt;I have many character variables that begin with "ACT_".&lt;BR /&gt;I need to change blanks (i.e. "") for these variables to "missing".&lt;BR /&gt;Any ideas how to do this?&lt;BR /&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2019 18:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/548867#M152255</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2019-04-05T18:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/548868#M152256</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array t(*)$ ACT_:;
do i=1 to dim(t);
if missing(t(i)) then t(i)='Missing';
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Apr 2019 18:23:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/548868#M152256</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-05T18:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/548873#M152258</link>
      <description>&lt;P&gt;A better demo:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Creating sample data HAVE*/
data have;
array ACT_(20) $ ;
call streaminit(5);
do i = 1 to 20;
   x = rand("Integer", 1, 20);  
	if mod(x,2)=0 then ACT_(i)='blah';
end;
drop x i;
run;

/*Your requirement to Impute word Missing to the blank values */
data want;
set have;
array t(*)$ ACT_:;
do i=1 to dim(t);
if missing(t(i)) then t(i)='Missing';
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Apr 2019 18:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/548873#M152258</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-05T18:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/548893#M152260</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18062"&gt;@gzr2mz39&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have many character variables that begin with "ACT_".&lt;BR /&gt;I need to change blanks (i.e. "") for these variables to "missing".&lt;BR /&gt;Any ideas how to do this?&lt;BR /&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do your current values actually have quote marks in them? If not then your value is already "missing".&lt;/P&gt;
&lt;P&gt;Run this code and look in the log to see if the message is present:&lt;/P&gt;
&lt;PRE&gt;data example;
   length var $ 10;
   var='';
   if missing(var) then put "WARNING: Value of VAR is missing!";
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Apr 2019 19:11:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/548893#M152260</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-05T19:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/549000#M152283</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Is there also a way to increase the length of each of the variables that start with ACT_: ?&lt;/P&gt;&lt;P&gt;Their current length is 4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2019 00:33:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/549000#M152283</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2019-04-06T00:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/549007#M152287</link>
      <description>&lt;P&gt;I'm afraid No for the vars those of its descriptors have been already read at compile time before execution. So, in that case, you may need a new set of vars in defined in another array and drop the set with smaller length after the look up&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18062"&gt;@gzr2mz39&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;Is there also a way to&lt;STRONG&gt; increase the length of each of the variables&lt;/STRONG&gt; that start with ACT_: ?&lt;/P&gt;
&lt;P&gt;Their current length is 4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Apr 2019 02:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/549007#M152287</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-06T02:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/771637#M244918</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to use your example code for e scenario where my condition to replace the values with missing observations is different. Instead of replacing missing observations with 'missing' in a character variable,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a list of numeric variables with a prefix &lt;STRONG&gt;var_name_:&amp;nbsp;&lt;/STRONG&gt;and I want to replace the existing observations which are numbers with missing . (later I want to assign other values)&lt;/P&gt;
&lt;P&gt;I tried the following code but I think my t(i) is not connected to my conditions to assign missing.&lt;/P&gt;
&lt;P&gt;I appreciate it if you may help me with this. Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	set have;
	array t(*) var_name_:;
	do i=1 to dim(t);
	if var_1 in (2,3) and var_2 in (1,3,4,5,6,7,10,13,14,16) then t(i)=.;
	end;
	drop i;
	run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 18:24:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/771637#M244918</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-10-01T18:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/771701#M244942</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84351"&gt;@Emma_at_SAS&lt;/a&gt;&amp;nbsp; Your condition isn't quite clear to me-&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;I have a list of numeric variables with a prefix&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;var_name_:&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;and I want to replace the existing observations which are numbers with missing ."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Do you want to replace missing numeric variables with something?&lt;/P&gt;
&lt;P&gt;2. Or do you want to replace some numbers with missing?-- This seems closer to your description. Your code seems okay. What do you see in LOG and output. What is not correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alternatively, please post a sample of your INPUT and expected OUTPUT. I can give it a go. Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 20:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/771701#M244942</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-10-01T20:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/771702#M244943</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/84351"&gt;@Emma_at_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This was answered in your other thread at &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-set-the-observations-for-a-groups-of-variables-with-a/m-p/771664#M244931" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-set-the-observations-for-a-groups-of-variables-with-a/m-p/771664#M244931&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best practice is to not change the subject of this thread (where the desired result was 'missing', you are asking for something different), and keep your question in its own thread.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 21:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/771702#M244943</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-01T21:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/771716#M244952</link>
      <description>Thank you, Paige Miller! I first tried using this thread to answer my question. Then looking at my question with a different perspective I got my answer in that other thread. Thank you for your follow-up.</description>
      <pubDate>Sat, 02 Oct 2021 02:06:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/771716#M244952</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-10-02T02:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: change the values of multiple variables with same prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/771717#M244953</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;for investigating my question. Your second point would be my question. As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;mentioned a more clear version of my question would be this&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-set-the-observations-for-a-groups-of-variables-with-a/m-p/771664#M244931" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Programming/How-to-set-the-observations-for-a-groups-of-variables...&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I would like to be able to do it with a loop as well but I cannot yet.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 02 Oct 2021 02:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-the-values-of-multiple-variables-with-same-prefix/m-p/771717#M244953</guid>
      <dc:creator>Emma_at_SAS</dc:creator>
      <dc:date>2021-10-02T02:08:06Z</dc:date>
    </item>
  </channel>
</rss>

