<?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: Base SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480075#M124033</link>
    <description>&lt;P&gt;Do this instead&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;_dumx = 999;
_dumc = "X";
array charv(*) _character_;
do _n_ =1 to dim(charv);
    charv(_n_)=coalescec(charv(_n_), '--');
    end;

array numv _numeric_;
do _n_ = 1 to dim(numv) ;
    numv(_n_) = coalesce(numv(_n_), 0);
    end;
drop _dum: ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 20 Jul 2018 21:34:50 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-07-20T21:34:50Z</dc:date>
    <item>
      <title>How to reference character variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480024#M124016</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we write IF condition for all character variables of dataset without mentioning their names in sas steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 19:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480024#M124016</guid>
      <dc:creator>petlove</dc:creator>
      <dc:date>2018-07-20T19:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480028#M124018</link>
      <description>&lt;P&gt;It depends.&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/135083"&gt;@petlove&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we write IF condition for all character variables of dataset without mentioning their names in sas steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 19:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480028#M124018</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-20T19:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480042#M124022</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/135083"&gt;@petlove&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can we write IF condition for all character variables of dataset without mentioning their names in sas steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&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;Provide a concrete example of what you want to accomplish. Depending on what the "if condition" is supposed to accomplish can make a big difference on what can be done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to do something with each variable at a time, probably yes. If you mean all variables at once then most likely no.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In between those two it really really depends on what you are trying to do as to the likelihood of practicality and complexity of code.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 19:30:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480042#M124022</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-07-20T19:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference character variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480046#M124023</link>
      <description>&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;PS. I modified your subject line as it was vague and non-informative.</description>
      <pubDate>Fri, 20 Jul 2018 19:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480046#M124023</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-20T19:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to reference character variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480055#M124025</link>
      <description>&lt;P&gt;Sometimes, yes... For example,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you want to check for empty strings&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if cmiss(of _character_) &amp;gt; 2 &amp;nbsp;then delete;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you want to check for the presence of a word&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if whichc("Error", of _character_) &amp;gt; 0 then delete;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you want to check for the presence of special characters&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;if anycntrl(cats(of _character_)) &amp;gt; 0 then delete;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you get the idea...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 19:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480055#M124025</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-20T19:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480073#M124031</link>
      <description>&lt;P&gt;Thank you for your response.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am replacing missing values of character variables to '--' and numeric values to 0 by using below array:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array charv(*) _character_;&lt;BR /&gt;do _n_ =1 to dim(charv);&lt;BR /&gt;charv(_n_)=coalescec(charv(_n_), '--');&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array numv _numeric_;&lt;BR /&gt;do over numv ;&lt;BR /&gt;if numv =. then numv =0;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run this code for any dataset and if dataset does not have character variable it shows below WARNING. In order to avoid, i was&amp;nbsp;thinking to write IF condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WARNING: Defining an array with zero elements.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 21:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480073#M124031</guid>
      <dc:creator>petlove</dc:creator>
      <dc:date>2018-07-20T21:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480075#M124033</link>
      <description>&lt;P&gt;Do this instead&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;_dumx = 999;
_dumc = "X";
array charv(*) _character_;
do _n_ =1 to dim(charv);
    charv(_n_)=coalescec(charv(_n_), '--');
    end;

array numv _numeric_;
do _n_ = 1 to dim(numv) ;
    numv(_n_) = coalesce(numv(_n_), 0);
    end;
drop _dum: ;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 21:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480075#M124033</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-20T21:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: Base SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480082#M124034</link>
      <description>&lt;P&gt;To eliminate the warning you can force SAS to create new variables and then drop them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pick names that you know your real data will never have.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is example you can run that uses SASHELP.CLASS and drops all of the numeric or characfer variables on the way in.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_nochar;
  set sashelp.class(drop=_character_) ;
  array _1 _numeric_ _drop_numeric_;
  array _2 _character_ _drop_character_ ;
  drop _drop_numeric_ _drop_character_ ;
  do over _1; _1=coalesce(_1,0); end;
  do over _2; _2=coalescec(_2,'--'); end;
run;

data test_nonumb;
  set sashelp.class(drop=_numeric_) ;
  array _1 _numeric_ _drop_numeric_;
  array _2 _character_ _drop_character_ ;
  drop _drop_numeric_ _drop_character_ ;
  do over _1; _1=coalesce(_1,0); end;
  do over _2; _2=coalescec(_2,'--'); end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jul 2018 22:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-reference-character-variables/m-p/480082#M124034</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-07-20T22:07:14Z</dc:date>
    </item>
  </channel>
</rss>

