<?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: Indicator Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Indicator-Variable/m-p/725307#M225257</link>
    <description>&lt;P&gt;SAS comparisons, such at &amp;gt; , &amp;lt; , LE and such will return 1 for "true" and 0 for false.&lt;/P&gt;
&lt;P&gt;So in a data step something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; indicator = (file_date&amp;gt;0);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However your "requirement" says "If FILE_DATE is greater than 0" which is not the same as " if there is no date then set is as a "0"&amp;nbsp; ". Unless you mean File_date=0 is supposed to be equivalent to "no date".&lt;/P&gt;
&lt;P&gt;If you mean that you have actual missing values then test the provided code. "Missing" is less than an any value so is not "&amp;gt;0".&lt;/P&gt;
&lt;P&gt;Another concern, if you have dates are any of them prior to the year 1960? If so are they "&amp;gt; 0" ??? Numerically dates in SAS are stored as the number of days from 1 Jan 1960. So dates prior to 1 Jan 1960 are negative numbers and 0 is 01JAN1960. If you need to consider dates prior to 1960 then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
    set have;
    indicator = not missing(file_date);
run;&lt;/PRE&gt;
&lt;P&gt;would be more appropriate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Mar 2021 00:23:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-03-11T00:23:36Z</dc:date>
    <item>
      <title>Indicator Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indicator-Variable/m-p/725304#M225254</link>
      <description>&lt;P&gt;I have a task that reads as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Create a new indicator variable to identify years where a restatement was issued.&amp;nbsp; If FILE_DATE is greater than 0, RESTATEMENT should equal 1 and otherwise should be 0."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So basically I need to create a new variable titled "restatement". FILE_DATE is currently, for example, in the format of 10MAR2021, but if there is no "file date" then it is set as "."&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What kind of function can I set and under what parameters/syntax to create a new variable that says if the file_date does have ANY date in it then to assign the new variable a "1" but if there is no date then set is as a "0"&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 00:00:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indicator-Variable/m-p/725304#M225254</guid>
      <dc:creator>krg1140</dc:creator>
      <dc:date>2021-03-11T00:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Indicator Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Indicator-Variable/m-p/725307#M225257</link>
      <description>&lt;P&gt;SAS comparisons, such at &amp;gt; , &amp;lt; , LE and such will return 1 for "true" and 0 for false.&lt;/P&gt;
&lt;P&gt;So in a data step something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; indicator = (file_date&amp;gt;0);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However your "requirement" says "If FILE_DATE is greater than 0" which is not the same as " if there is no date then set is as a "0"&amp;nbsp; ". Unless you mean File_date=0 is supposed to be equivalent to "no date".&lt;/P&gt;
&lt;P&gt;If you mean that you have actual missing values then test the provided code. "Missing" is less than an any value so is not "&amp;gt;0".&lt;/P&gt;
&lt;P&gt;Another concern, if you have dates are any of them prior to the year 1960? If so are they "&amp;gt; 0" ??? Numerically dates in SAS are stored as the number of days from 1 Jan 1960. So dates prior to 1 Jan 1960 are negative numbers and 0 is 01JAN1960. If you need to consider dates prior to 1960 then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
    set have;
    indicator = not missing(file_date);
run;&lt;/PRE&gt;
&lt;P&gt;would be more appropriate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Mar 2021 00:23:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Indicator-Variable/m-p/725307#M225257</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-11T00:23:36Z</dc:date>
    </item>
  </channel>
</rss>

