<?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: Creating if then column based on if cell is blank in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-if-then-column-based-on-if-cell-is-blank/m-p/757712#M239205</link>
    <description>&lt;P&gt;Can you describe how you will use that indicator?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may not need a new variable. When value is based on a single variable often a simple format can be used to display desired text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
value $blank
' '='BLANK'
other='NOTBLANK'
;
run;&lt;/PRE&gt;
&lt;P&gt;Then use the format to display the existing character variable. Or use Newvar=put(var,$blank.); Formatted values can be used by most procedures though may need to explicitly allow use of missing values depending on procedure.&lt;/P&gt;
&lt;P&gt;Similar can be done with numeric values and numeric format.&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jul 2021 14:32:30 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-07-28T14:32:30Z</dc:date>
    <item>
      <title>Creating if then column based on if cell is blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-if-then-column-based-on-if-cell-is-blank/m-p/757567#M239149</link>
      <description>&lt;P&gt;I would like to create a new column called 'Indicator' which is equal to "NOT_BLANK" if 'field' is not blank and "BLANK" if 'field' is blank.&lt;/P&gt;
&lt;P&gt;How I would do this in excel is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sasprogramming_0-1627433377422.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61926iFF11871ADEB3E97F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="sasprogramming_0-1627433377422.png" alt="sasprogramming_0-1627433377422.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;How can I do this in SAS? Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Current data:&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE width="80"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="80"&gt;Field&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A001_B001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;C002&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;C002_A001&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;B002&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;STRONG&gt;Desired data:&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE width="170"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="80"&gt;Field&lt;/TD&gt;
&lt;TD width="90"&gt;Indicator&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A001_B001&lt;/TD&gt;
&lt;TD&gt;NOTBLANK&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A001&lt;/TD&gt;
&lt;TD&gt;NOTBLANK&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;BLANK&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;C002&lt;/TD&gt;
&lt;TD&gt;NOTBLANK&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;C002_A001&lt;/TD&gt;
&lt;TD&gt;NOTBLANK&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;B002&lt;/TD&gt;
&lt;TD&gt;NOTBLANK&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Wed, 28 Jul 2021 00:50:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-if-then-column-based-on-if-cell-is-blank/m-p/757567#M239149</guid>
      <dc:creator>sasprogramming</dc:creator>
      <dc:date>2021-07-28T00:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating if then column based on if cell is blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-if-then-column-based-on-if-cell-is-blank/m-p/757570#M239151</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;INDICATOR = ifc(missing(FIELD),'BLANK','NOTBLANK');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Don't forget the set the length of INDICATOR or it will default to a length of 200.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 01:36:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-if-then-column-based-on-if-cell-is-blank/m-p/757570#M239151</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-07-28T01:36:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating if then column based on if cell is blank</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-if-then-column-based-on-if-cell-is-blank/m-p/757712#M239205</link>
      <description>&lt;P&gt;Can you describe how you will use that indicator?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may not need a new variable. When value is based on a single variable often a simple format can be used to display desired text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
value $blank
' '='BLANK'
other='NOTBLANK'
;
run;&lt;/PRE&gt;
&lt;P&gt;Then use the format to display the existing character variable. Or use Newvar=put(var,$blank.); Formatted values can be used by most procedures though may need to explicitly allow use of missing values depending on procedure.&lt;/P&gt;
&lt;P&gt;Similar can be done with numeric values and numeric format.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jul 2021 14:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-if-then-column-based-on-if-cell-is-blank/m-p/757712#M239205</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-07-28T14:32:30Z</dc:date>
    </item>
  </channel>
</rss>

