<?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: Check for Zero in Input Statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129372#M26396</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Tom!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 24 Sep 2012 22:17:10 GMT</pubDate>
    <dc:creator>Linlin</dc:creator>
    <dc:date>2012-09-24T22:17:10Z</dc:date>
    <item>
      <title>Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129366#M26390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm importing some data that includes several columns that uses the YYMMDD8. informat. Most of the data is formatted correctly (eg 20090125), but some fields are just a series of zeros (00000000). I'd like a missing value for the records that have zeros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can make it work by importing it as a character variable and then using a statement like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if char_field ^= '00000000' then date_field = input(char_field, YYMMDD8.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This seems clunky and is a bit tedious when there are several columns. Is there a way to use informats to check for a zero value? Or is there a better way to approach this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for your help,&lt;BR /&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 16:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129366#M26390</guid>
      <dc:creator>rpmartin</dc:creator>
      <dc:date>2012-09-24T16:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129367#M26391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use a custom informat.&amp;nbsp; You can nest the format so that you only need to define how to handle the special case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc format ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; invalue zdate '00000000'=. other=[yymmdd8.] ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input date zdate8.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; format date yymmdd10.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put date= +1 _infile_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;00000000&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;20100608&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 17:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129367#M26391</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-09-24T17:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129368#M26392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Last time I worked with such imports reading text or csv files if the the data was out of range for a specified informat like this the result was missing. Year 0000 is valid but month and day 0 are both invalid and should result in missing. How are you importing the data? (HInt: wizards are pretty stupid about some values).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 17:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129368#M26392</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2012-09-24T17:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129369#M26393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Tom. That's what I was looking for. I didn't realize you could nest formats which is super useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 18:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129369#M26393</guid>
      <dc:creator>rpmartin</dc:creator>
      <dc:date>2012-09-24T18:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129370#M26394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;proc format ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; invalue zdate '00000000'=. other=[yymmdd8.] ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;when I changed "other=[yymmdd8.]" to "other=yymmdd8." it also worked, it did not work when I changed it to "other=(yymmdd8.) or other={yymmdd8.}". Do we have to use "[ ]"?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 20:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129370#M26394</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-09-24T20:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129371#M26395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to the SAS 9.2 manual you should use square brackets [ and ] or you can use two character sequence (| and |) instead.&lt;/P&gt;&lt;P&gt;But as you discovered they are not actually required. At least with 6.12, 8.2 and 9.2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="strongEmph" style="font-weight: bold; font-style: italic;"&gt;existing-informat&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0px 0px 1.4em;"&gt;is an informat that is supplied by SAS or a user-defined informat. The informat you are creating uses the existing informat to convert the raw data that match &lt;SPAN class="emph" style="font-style: italic;"&gt;value-or-range&lt;/SPAN&gt; on the left side of the equal sign. If you use an existing informat, then enclose the informat name in square brackets (for example, [date9.]) or with parentheses and vertical bars, for example (|date9.|). &lt;SPAN class="emph" style="font-style: italic;"&gt;Do not enclose the name of the existing informat in single quotation marks.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 21:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129371#M26395</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-09-24T21:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129372#M26396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Tom!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Sep 2012 22:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129372#M26396</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-09-24T22:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129373#M26397</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not use double question symbol to let sas do it for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data test;
&amp;nbsp; input date ?? yymmdd10.;
&amp;nbsp; format date yymmdd10.;
&amp;nbsp; put date= +1 _infile_;
cards;
00000000
20100608
;
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>Tue, 25 Sep 2012 04:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129373#M26397</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-09-25T04:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129374#M26398</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any link/documentations on this usage of ??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Sep 2012 13:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129374#M26398</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-09-25T13:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129375#M26399</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000180357.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000180357.htm"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000180357.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Sep 2012 14:06:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129375#M26399</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-09-25T14:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Check for Zero in Input Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129376#M26400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, LinLin. I should have checked first.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Sep 2012 14:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Check-for-Zero-in-Input-Statement/m-p/129376#M26400</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-09-25T14:11:09Z</dc:date>
    </item>
  </channel>
</rss>

