<?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: Coding an indicator 0-1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Coding-an-indicator-0-1/m-p/660115#M197630</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333217"&gt;@ma23nu32el&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;I have to create a 0-1 variable called&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;dblehdr&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;that indicates whether the triple play occurred during a game that was part of a double-header this is what I have but is not returning the value that I need, what I'm doing wrong?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data trp2;&lt;BR /&gt;infile trpd2 DLM=',' DSD Firstobs=2 missover;&lt;BR /&gt;input Year Date :$12. Game IAT Team :$12. LG $ HA $ oppteam :$12.&lt;BR /&gt;OLG $ players :$150. inn $ SCRVH $ batter :$20. runner1 :$20. runner2 :$20.&lt;BR /&gt;runner3 :$20.;&lt;BR /&gt;if Date='' then delete;&lt;BR /&gt;if dblehdr= indexc(Date,'()') then do;&lt;BR /&gt;dblehdr=1;&lt;BR /&gt;end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You code does not show where dblehdr is read from. So this statement&lt;/P&gt;
&lt;PRE&gt;if dblehdr= indexc(Date,'()') then do;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;has&amp;nbsp; a serious problem because you are using the value of the variable dblehdr in the IF before it has a value assigned. So the if is always false. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SAS will return 0 for "false" and 1 for "true" when using logical comparisons. So &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214340"&gt;@smantha&lt;/a&gt;'s code will assign a 1 if the "date" has either a ( or ) character in it. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And what value would indicate a triple play? What variable?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jun 2020 17:07:28 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-06-16T17:07:28Z</dc:date>
    <item>
      <title>Coding an indicator 0-1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-an-indicator-0-1/m-p/660104#M197626</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have to create a 0-1 variable called&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;dblehdr&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;that indicates whether the triple play occurred during a game that was part of a double-header this is what I have but is not returning the value that I need, what I'm doing wrong?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data trp2;&lt;BR /&gt;infile trpd2 DLM=',' DSD Firstobs=2 missover;&lt;BR /&gt;input Year Date :$12. Game IAT Team :$12. LG $ HA $ oppteam :$12.&lt;BR /&gt;OLG $ players :$150. inn $ SCRVH $ batter :$20. runner1 :$20. runner2 :$20.&lt;BR /&gt;runner3 :$20.;&lt;BR /&gt;if Date='' then delete;&lt;BR /&gt;if dblehdr= indexc(Date,'()') then do;&lt;BR /&gt;dblehdr=1;&lt;BR /&gt;end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 16:40:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-an-indicator-0-1/m-p/660104#M197626</guid>
      <dc:creator>ma23nu32el</dc:creator>
      <dc:date>2020-06-16T16:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Coding an indicator 0-1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-an-indicator-0-1/m-p/660108#M197627</link>
      <description>&lt;P&gt;sample input data would be good. How is date coded for double header? does it have two values in parantheses. dblehdr is not previously defined so it will never be true. try the code below instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data trp2;
infile trpd2 DLM=',' DSD Firstobs=2 missover;
input Year Date :$12. Game IAT Team :$12. LG $ HA $ oppteam :$12.
OLG $ players :$150. inn $ SCRVH $ batter :$20. runner1 :$20. runner2 :$20.
runner3 :$20.;
if Date='' then delete;
dblehdr= (indexc(Date,'()')&amp;gt;0) ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2020 16:48:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-an-indicator-0-1/m-p/660108#M197627</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-16T16:48:58Z</dc:date>
    </item>
    <item>
      <title>Re: Coding an indicator 0-1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-an-indicator-0-1/m-p/660115#M197630</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/333217"&gt;@ma23nu32el&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;I have to create a 0-1 variable called&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;dblehdr&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;that indicates whether the triple play occurred during a game that was part of a double-header this is what I have but is not returning the value that I need, what I'm doing wrong?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data trp2;&lt;BR /&gt;infile trpd2 DLM=',' DSD Firstobs=2 missover;&lt;BR /&gt;input Year Date :$12. Game IAT Team :$12. LG $ HA $ oppteam :$12.&lt;BR /&gt;OLG $ players :$150. inn $ SCRVH $ batter :$20. runner1 :$20. runner2 :$20.&lt;BR /&gt;runner3 :$20.;&lt;BR /&gt;if Date='' then delete;&lt;BR /&gt;if dblehdr= indexc(Date,'()') then do;&lt;BR /&gt;dblehdr=1;&lt;BR /&gt;end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You code does not show where dblehdr is read from. So this statement&lt;/P&gt;
&lt;PRE&gt;if dblehdr= indexc(Date,'()') then do;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;has&amp;nbsp; a serious problem because you are using the value of the variable dblehdr in the IF before it has a value assigned. So the if is always false. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SAS will return 0 for "false" and 1 for "true" when using logical comparisons. So &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214340"&gt;@smantha&lt;/a&gt;'s code will assign a 1 if the "date" has either a ( or ) character in it. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And what value would indicate a triple play? What variable?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 17:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-an-indicator-0-1/m-p/660115#M197630</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-16T17:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Coding an indicator 0-1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Coding-an-indicator-0-1/m-p/660118#M197631</link>
      <description>I would recommend separating your steps. First read the data in. Make sure that is working correctly and then do your cleaning in a second step. This allows you to test each stage separately and more easily identify errors.&lt;BR /&gt;&lt;BR /&gt;As BallardW indicated, the variable, dblehdr, is never read in or exists prior to usage so that will not work.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data trp2;&lt;BR /&gt;infile trpd2 DLM=',' DSD Firstobs=2 missover;&lt;BR /&gt;input Year Date :$12. Game IAT Team :$12. LG $ HA $ oppteam :$12.&lt;BR /&gt;OLG $ players :$150. inn $ SCRVH $ batter :$20. runner1 :$20. runner2 :$20.&lt;BR /&gt;runner3 :$20.;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;data trp3;&lt;BR /&gt;set trp2;&lt;BR /&gt;if Date='' then delete;&lt;BR /&gt;if dblehdr= indexc(Date,'()') then &lt;BR /&gt;dblehdr=1;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 16 Jun 2020 17:21:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Coding-an-indicator-0-1/m-p/660118#M197631</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-16T17:21:00Z</dc:date>
    </item>
  </channel>
</rss>

