<?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: Writing special character star &amp;quot;*&amp;quot; for blank or missing. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861413#M340276</link>
    <description>&lt;P&gt;If it's character, and '.' means missing, I think it's better to convert to a character misssing (blank) rather than to an asterisk.&amp;nbsp; If it's a character missing, then SAS knows that is missing.&amp;nbsp; If it's a *, then you as the programmer need to remember that * means missing and code around it.&amp;nbsp; I like the format approach that Bart showed.&amp;nbsp; It allows you to keep the value as missing, but display it as an asterisk, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  do x = "A","B"," ",".","D";
    output ;
  end;
run ;

proc format;
  value $ missinAsterisk 
    ' '='*'
    other = [$char8.]
  ;
run;

data want ;
  set have ;
  array chars {*} _character_ ;
  do i=1 to dim(chars) ;
    if chars{i}='.' then call missing(chars{i}) ;
  end ;
  drop i ;

  format _character_ $missinAsterisk. ;
run ;

proc print data=want ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Feb 2023 14:58:10 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2023-02-28T14:58:10Z</dc:date>
    <item>
      <title>Writing special character star "*" for blank or missing.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861374#M340258</link>
      <description>&lt;P&gt;Hi all. I hope everyone is healthy.&lt;/P&gt;
&lt;P&gt;Hopefully a very simple question. How to write * when the data are blank or have "."?&lt;/P&gt;
&lt;P&gt;I have this code&lt;/P&gt;
&lt;P&gt;if tbr2="." then tbr2="*";&lt;BR /&gt;if tpr2="." then tpr2="*";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I -think- the data set has "." as values that mean blank or missing, but that could be the problem too.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, first question: would that code work, if the values are "."?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 13:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861374#M340258</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2023-02-28T13:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Writing special character star "*" for blank or missing.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861381#M340260</link>
      <description>&lt;P&gt;1) If you variable is numeric you won't be able to replace it with "*", in this case you could only write a format that displays missing value as asterisk, something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value missinAsterisk
  low-high = [best32.]
  other = "*"
  ;
run;

data _null_;
  do i = -1,100,3.14,.,.A,.Z,._,-17,42;
    put i missinAsterisk.;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) If you have character variable then the condition:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;var = " "&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;checks if the variable is blank (missing). In this case you can do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if tbr2=" " then tbr2="*";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;3) If your variable is character and contains "."(dot) then it is not missing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; but... if you want to replace all dots in your variable you could try to use translate() function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  do x = "...", ".", "  .", ". .";
     y = translate(x,"*",".");
     put x= / y=;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&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;</description>
      <pubDate>Tue, 28 Feb 2023 14:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861381#M340260</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-02-28T14:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Writing special character star "*" for blank or missing.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861386#M340262</link>
      <description>Hi Bart. Good point. I checked. The variable is character, so I'll try some of your solutions. Thanks.</description>
      <pubDate>Tue, 28 Feb 2023 14:15:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861386#M340262</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2023-02-28T14:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Writing special character star "*" for blank or missing.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861413#M340276</link>
      <description>&lt;P&gt;If it's character, and '.' means missing, I think it's better to convert to a character misssing (blank) rather than to an asterisk.&amp;nbsp; If it's a character missing, then SAS knows that is missing.&amp;nbsp; If it's a *, then you as the programmer need to remember that * means missing and code around it.&amp;nbsp; I like the format approach that Bart showed.&amp;nbsp; It allows you to keep the value as missing, but display it as an asterisk, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  do x = "A","B"," ",".","D";
    output ;
  end;
run ;

proc format;
  value $ missinAsterisk 
    ' '='*'
    other = [$char8.]
  ;
run;

data want ;
  set have ;
  array chars {*} _character_ ;
  do i=1 to dim(chars) ;
    if chars{i}='.' then call missing(chars{i}) ;
  end ;
  drop i ;

  format _character_ $missinAsterisk. ;
run ;

proc print data=want ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2023 14:58:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861413#M340276</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2023-02-28T14:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: Writing special character star "*" for blank or missing.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861425#M340282</link>
      <description>&lt;P&gt;Thanks Bart and Quentin.&amp;nbsp;I examined the data set once more, because of your responses, and it turns out the problem was that the value wasn't "." but "&amp;nbsp; &amp;nbsp;.". It had spaces in front of the period. I put in the spaces, and that worked.&lt;/P&gt;
&lt;P&gt;if tbr2=" ." then tbr2="*";&lt;BR /&gt;if tpr2=" ." then tpr2="*";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again, and I apologize for not examining the data more closely in the first place. Who would have thought!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gene&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 15:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Writing-special-character-star-quot-quot-for-blank-or-missing/m-p/861425#M340282</guid>
      <dc:creator>geneshackman</dc:creator>
      <dc:date>2023-02-28T15:09:43Z</dc:date>
    </item>
  </channel>
</rss>

