<?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: Set a value for all missing character variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111603#M23120</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use 'do over' to save some typing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt; set class;&lt;/P&gt;&lt;P&gt; array _a $ _character_;&lt;/P&gt;&lt;P&gt; do over _a;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if missing(_a) then _a='UNKNOWN';&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 May 2012 12:12:17 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-05-11T12:12:17Z</dc:date>
    <item>
      <title>Set a value for all missing character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111600#M23117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am creating a set of tables and want to replace all character variables that are missing with a rudimentary value like 'UNKNOWN' for example.&amp;nbsp; I want to do this dynamically: e.g. not have to explicitly set the variable value to 'UNKNOWN'.&amp;nbsp; It should apply to all character variables.&amp;nbsp; I can't use a format to set it at runtime it needs to be written to the dataset.&amp;nbsp; I was hoping something like if(strip(_character_))='' then _character_ = 'UNKNOWN' works however this doesn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas from anyone?&amp;nbsp; Any help is appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 11:15:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111600#M23117</guid>
      <dc:creator>CameronL</dc:creator>
      <dc:date>2012-05-11T11:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Set a value for all missing character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111601#M23118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;length a b c d $8;&lt;/P&gt;&lt;P&gt;a='abc';&lt;/P&gt;&lt;P&gt;b='efg';&lt;/P&gt;&lt;P&gt;c=' ';&lt;/P&gt;&lt;P&gt;d=' ';&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array _abc(*) _character_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do _n_=1 to dim(_abc);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _abc(_n_) =' ' then _abc(_n_)='UNKNOWN';&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc print;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 11:29:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111601#M23118</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-05-11T11:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Set a value for all missing character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111602#M23119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That would be a problem when your character variable is not long enough to hold UNKNOWN.&lt;/P&gt;&lt;P&gt;Thus, Assuming your character variable is long enough.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data class;
 set sashelp.class;
 if _n_ le ceil(ranuni(-1)*10) then call missing(name);
run;
data want ;
 set class;
 array _a{*} $ _character_;
 do i=1 to dim(_a);
&amp;nbsp; if missing(_a{i}) then _a{i}='UNKNOWN';
 end;
 drop i;
run;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 11:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111602#M23119</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-05-11T11:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Set a value for all missing character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111603#M23120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use 'do over' to save some typing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt; set class;&lt;/P&gt;&lt;P&gt; array _a $ _character_;&lt;/P&gt;&lt;P&gt; do over _a;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if missing(_a) then _a='UNKNOWN';&lt;/P&gt;&lt;P&gt; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 12:12:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111603#M23120</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-05-11T12:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Set a value for all missing character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111604#M23121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;hi ... another idea ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt;"&gt;&lt;STRONG&gt;data want;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt;"&gt;&lt;STRONG&gt;set have; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt;"&gt;&lt;STRONG&gt;array ch(*) _character_;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt;"&gt;&lt;STRONG&gt;do _n_ = 1 to dim(ch);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ch(_n_) = coalescec(ch(_n_), 'UNKNOWN');&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt;"&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;ps ... &lt;A href="http://www.sascommunity.org/wiki/Tips:Replace_Missing_Character_Values_with_a_Character_String" title="http://www.sascommunity.org/wiki/Tips:Replace_Missing_Character_Values_with_a_Character_String"&gt;http://www.sascommunity.org/wiki/Tips:Replace_Missing_Character_Values_with_a_Character_String&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 May 2012 15:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111604#M23121</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-05-11T15:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Set a value for all missing character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111605#M23122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the responses everyone!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 May 2012 06:14:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Set-a-value-for-all-missing-character-variables/m-p/111605#M23122</guid>
      <dc:creator>CameronL</dc:creator>
      <dc:date>2012-05-12T06:14:34Z</dc:date>
    </item>
  </channel>
</rss>

