<?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: How to replace . to 9 on a particular variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843613#M333515</link>
    <description>Its just a question, if I wanna replace . with 9 only on Rank and Rollno not on Plan&lt;BR /&gt;I forgot to define&lt;BR /&gt;Name(Char) Rank(Num) RollNO(Num) Plan(Num)&lt;BR /&gt;Data output;&lt;BR /&gt;set input;&lt;BR /&gt;Array num _numeric_;&lt;BR /&gt;do over nums;&lt;BR /&gt;if Num=. then nums=9&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;Input :&lt;BR /&gt;Name Rank RollNO Plan&lt;BR /&gt;Animesh 1 2 55&lt;BR /&gt;Mardi . . 65&lt;BR /&gt;&lt;BR /&gt;Output:&lt;BR /&gt;Name Rank RollNO Plan&lt;BR /&gt;Animesh 1 2 55&lt;BR /&gt;Mardi 9 9 65&lt;BR /&gt;</description>
    <pubDate>Thu, 10 Nov 2022 16:01:37 GMT</pubDate>
    <dc:creator>animesh123</dc:creator>
    <dc:date>2022-11-10T16:01:37Z</dc:date>
    <item>
      <title>How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843601#M333506</link>
      <description>&lt;P&gt;The below code will change the output data&amp;nbsp; from&lt;STRONG&gt; . to 9&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;set input;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Array num&amp;nbsp; _numeric_;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;do over nums;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if Num=. then nums=9&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Let say if we wanna change&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;. to 9 on a particular variable like only on(&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Rank RollNO&amp;nbsp; )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;, As if i have a table and the variable are&lt;/P&gt;&lt;P&gt;Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Rank&amp;nbsp; &amp;nbsp; RollNO&amp;nbsp; &amp;nbsp; Plan&amp;nbsp;&lt;/P&gt;&lt;P&gt;Animesh&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;55&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Mardi&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;65&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 15:14:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843601#M333506</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-11-10T15:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843603#M333508</link>
      <description>&lt;P&gt;This isn't hard to do, but missings shouldn't usually be replaced by a numeric value. If you ever want to then find a mean or a sum, the value of 9 causes the mean or sum to be incorrect. So I advise against doing this. What's wrong with leaving this as a missing?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 15:16:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843603#M333508</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-10T15:16:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843604#M333509</link>
      <description>There is nothing with missing, But if my requirement are to Replace . with 9 , What does I required to change in my present below code&lt;BR /&gt;Data output;&lt;BR /&gt;set input;&lt;BR /&gt;Array num _numeric_;&lt;BR /&gt;do over nums;&lt;BR /&gt;if Num=. then nums=9&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;Input :&lt;BR /&gt;Name Rank RollNO Plan&lt;BR /&gt;Animesh 1 2 55&lt;BR /&gt;Mardi . . 65&lt;BR /&gt;&lt;BR /&gt;Output:&lt;BR /&gt;Name Rank RollNO Plan&lt;BR /&gt;Animesh 1 2 55&lt;BR /&gt;Mardi 9 9 65&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Nov 2022 15:26:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843604#M333509</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-11-10T15:26:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843608#M333512</link>
      <description>&lt;P&gt;Why are you looping over an array named NUMS that you never defined?&lt;/P&gt;
&lt;P&gt;Why are you changing the value of NUMS based on whether or not the value in NUM is a missing value?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And WHY do you want to convert missing values into valid numbers?&amp;nbsp; That will make your variables difficult (if not impossible) to work with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you definitely do NOT want to change the missing values to 9 in a variable like PLAN that clearly seems to allow values that are larger than 9.&amp;nbsp; Why would you want to convert missing PLAN to PLAN number 9?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 15:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843608#M333512</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-10T15:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843611#M333513</link>
      <description>&lt;P&gt;This is not correct code, NUM/NUMS are being used interchangeabley and I don't recommend using implicit arrays and do over without indexes if you don't understand arrays well.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430763"&gt;@animesh123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The below code will change the output data&amp;nbsp; from&lt;STRONG&gt; . to 9&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Data output;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;set input;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Array num&amp;nbsp; _numeric_;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;do over nums;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if Num=. then nums=9&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;Let say if we wanna change&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;. to 9 on a particular variable like only on(&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Rank RollNO&amp;nbsp; )&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;, As if i have a table and the variable are&lt;/P&gt;
&lt;P&gt;Name&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Rank&amp;nbsp; &amp;nbsp; RollNO&amp;nbsp; &amp;nbsp; Plan&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Animesh&amp;nbsp; &amp;nbsp; 1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;55&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Mardi&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;65&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;For a single variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
set have;

if rank = . then rank=9;


run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For multiple variables use an array but explicitly list the variables in the array:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
set have;
array _nums(*) rank rollNo; *list variables to convert here;

do i=1 to dim(_nums);

     if _nums(i) = . then _nums(i) = 9;

end;


run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Nov 2022 15:53:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843611#M333513</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-10T15:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843613#M333515</link>
      <description>Its just a question, if I wanna replace . with 9 only on Rank and Rollno not on Plan&lt;BR /&gt;I forgot to define&lt;BR /&gt;Name(Char) Rank(Num) RollNO(Num) Plan(Num)&lt;BR /&gt;Data output;&lt;BR /&gt;set input;&lt;BR /&gt;Array num _numeric_;&lt;BR /&gt;do over nums;&lt;BR /&gt;if Num=. then nums=9&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;Input :&lt;BR /&gt;Name Rank RollNO Plan&lt;BR /&gt;Animesh 1 2 55&lt;BR /&gt;Mardi . . 65&lt;BR /&gt;&lt;BR /&gt;Output:&lt;BR /&gt;Name Rank RollNO Plan&lt;BR /&gt;Animesh 1 2 55&lt;BR /&gt;Mardi 9 9 65&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Nov 2022 16:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843613#M333515</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-11-10T16:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843615#M333516</link>
      <description>&lt;P&gt;Here's a tutorial on using Arrays in SAS&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 16:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843615#M333516</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-10T16:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843627#M333522</link>
      <description>&lt;P&gt;Then don't include PLAN in the list of variables you put into the array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array nums rank rollno ;
do over nums;
  nums=coalesce(nums,9);
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you have a LOT of variables and are too lazy to figure out how specify them all without including plan then exclude it inside the loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array nums _numeric_ ;
do over nums;
  if lowcase(vname(nums)) ne 'plan' then 
    nums=coalesce(nums,9)
  ;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or define the array BEFORE the data step complier knows about PLAN so it is not included by the variable list _NUMERIC_.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have(drop=plan);
  array nums _numeric_  ;
  set have;
  do over nums;
    nums=coalesce(nums,9);
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;But you still did not explain WHY you want to make your variables unusable.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;This looks like an XY problem.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://xyproblem.info/" target="_blank" rel="noopener"&gt;https://xyproblem.info/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 16:58:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843627#M333522</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-10T16:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843633#M333523</link>
      <description>Hey Tom&lt;BR /&gt;&lt;BR /&gt;Thanks. For me its usable data .&lt;BR /&gt;&lt;BR /&gt;To answer your question All the data will get drop in further process&lt;BR /&gt;wherever it contains 9 .&lt;BR /&gt;I am making it 9 so the other data dont get messed up&lt;BR /&gt;before the code was changing all of the variable to 9 which i dont required&lt;BR /&gt;</description>
      <pubDate>Thu, 10 Nov 2022 17:07:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843633#M333523</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-11-10T17:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843638#M333524</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430763"&gt;@animesh123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hey Tom&lt;BR /&gt;&lt;BR /&gt;Thanks. For me its usable data .&lt;BR /&gt;&lt;BR /&gt;To answer your question All the data will get drop in further process&lt;BR /&gt;wherever it contains 9 .&lt;BR /&gt;I am making it 9 so the other data dont get messed up&lt;BR /&gt;before the code was changing all of the variable to 9 which i dont required&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Huh?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Why not just remove whatever logic was being used that dropped the values that had a 9?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Or did you mean the missing values were dropped?&lt;/P&gt;
&lt;P&gt;If so then what analysis are you doing that is dropping the missing observations?&amp;nbsp; Any analysis of say the MEAN of the variable SHOULD exclude the missing values.&amp;nbsp; Replacing missing with 9 and then trying to calculate the MEAN will result in a meaningless value.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 17:23:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843638#M333524</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-10T17:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843649#M333526</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430763"&gt;@animesh123&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;I am making it 9 so the other data dont get messed up&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Many SAS PROCs have a MISSING option, "so the other data don't get messed up". But enough beating around the bush. Please explain what you are doing where other data can get messed up. We need to know, because I think your attempts to turn a missing into a 9 are very misguided. But maybe if we knew what you are doing, we could suggest better methods, or maybe even we could see that its okay to turn a missing into a 9 (but I consider this unlikely).&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Tell us what you are doing that requires you to turn a missing into a 9&lt;/P&gt;</description>
      <pubDate>Thu, 10 Nov 2022 17:56:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843649#M333526</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-10T17:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843651#M333527</link>
      <description>So to provide you the answer for why. I need to explain you the explanation whole process of where and what is .&lt;BR /&gt;Hey man I am just new guy working in SAS tool had a little bit of experience not so much just fumbled on one of the code where I need to replace . to 9 .its simple as that&lt;BR /&gt;to tell you the truth some of your why question i didn't even get&lt;BR /&gt;But yeah Thank you very much for you Answer</description>
      <pubDate>Thu, 10 Nov 2022 18:06:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843651#M333527</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-11-10T18:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace . to 9 on a particular variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843656#M333530</link>
      <description>Thanks Reeza, I have used it like this&lt;BR /&gt;Data output;&lt;BR /&gt;Set input;&lt;BR /&gt;Array Nums Rank Rollno;&lt;BR /&gt;do over Nums;&lt;BR /&gt;if Num=. then Nums=9&lt;BR /&gt;end;</description>
      <pubDate>Thu, 10 Nov 2022 18:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-replace-to-9-on-a-particular-variable/m-p/843656#M333530</guid>
      <dc:creator>animesh123</dc:creator>
      <dc:date>2022-11-10T18:10:46Z</dc:date>
    </item>
  </channel>
</rss>

