<?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: SAS misidentifying variable responses - no trailing or leading blanks in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-misidentifying-variable-responses-no-trailing-or-leading/m-p/719987#M222988</link>
    <description>&lt;P&gt;Order of operations, put the SET statement BEFORE the logic code - you need data to operate on. &lt;BR /&gt;&lt;BR /&gt;Note that you'll need to replace your NT data set first from the original source as you've likely messed it up. This is why that style of programming, using the same name in the DATA and SET statements is not recommended.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4" color="#FF6600"&gt;&lt;STRONG&gt;DATA INJLIB.NT2;
SET INJLIB.NT;&lt;/STRONG&gt;&lt;/FONT&gt;
IF NEWICD ='W00' THEN PROB1='W00';
ELSE IF NEWICD NE 'W00' THEN PROB1 ='NO';

RUN;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/197740"&gt;@Angmar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm having difficulty figuring out why SAS is misidentifying variable responses. I'd like to create a new binary variable of 'W00' and 'NO' based on whether the variable response for NEWICD is 'W00' (i.e., if the response is 'W00' for NEWICD, then PROB1 will be 'W00' and if not PROB1 will be 'NO'). My code is:&lt;/P&gt;
&lt;P&gt;DATA INJLIB.NT;&lt;BR /&gt;IF NEWICD ='W00' THEN PROB1='W00';&lt;BR /&gt;ELSE IF NEWICD NE 'W00' THEN PROB1 ='NO';&lt;BR /&gt;SET INJLIB.NT;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;However, these are the first ten lines of the output data:&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="Angmar_0-1613584757942.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54858i81C4FAC1ADD5AF24/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Angmar_0-1613584757942.png" alt="Angmar_0-1613584757942.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Why is this happening?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Feb 2021 18:06:18 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-02-17T18:06:18Z</dc:date>
    <item>
      <title>SAS misidentifying variable responses - no trailing or leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-misidentifying-variable-responses-no-trailing-or-leading/m-p/719985#M222986</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm having difficulty figuring out why SAS is misidentifying variable responses. I'd like to create a new binary variable of 'W00' and 'NO' based on whether the variable response for NEWICD is 'W00' (i.e., if the response is 'W00' for NEWICD, then PROB1 will be 'W00' and if not PROB1 will be 'NO'). My code is:&lt;/P&gt;
&lt;P&gt;DATA INJLIB.NT;&lt;BR /&gt;IF NEWICD ='W00' THEN PROB1='W00';&lt;BR /&gt;ELSE IF NEWICD NE 'W00' THEN PROB1 ='NO';&lt;BR /&gt;SET INJLIB.NT;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;However, these are the first ten lines of the output data:&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="Angmar_0-1613584757942.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54858i81C4FAC1ADD5AF24/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Angmar_0-1613584757942.png" alt="Angmar_0-1613584757942.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Why is this happening?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 17:59:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-misidentifying-variable-responses-no-trailing-or-leading/m-p/719985#M222986</guid>
      <dc:creator>Angmar</dc:creator>
      <dc:date>2021-02-17T17:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS misidentifying variable responses - no trailing or leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-misidentifying-variable-responses-no-trailing-or-leading/m-p/719987#M222988</link>
      <description>&lt;P&gt;Order of operations, put the SET statement BEFORE the logic code - you need data to operate on. &lt;BR /&gt;&lt;BR /&gt;Note that you'll need to replace your NT data set first from the original source as you've likely messed it up. This is why that style of programming, using the same name in the DATA and SET statements is not recommended.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="4" color="#FF6600"&gt;&lt;STRONG&gt;DATA INJLIB.NT2;
SET INJLIB.NT;&lt;/STRONG&gt;&lt;/FONT&gt;
IF NEWICD ='W00' THEN PROB1='W00';
ELSE IF NEWICD NE 'W00' THEN PROB1 ='NO';

RUN;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/197740"&gt;@Angmar&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I'm having difficulty figuring out why SAS is misidentifying variable responses. I'd like to create a new binary variable of 'W00' and 'NO' based on whether the variable response for NEWICD is 'W00' (i.e., if the response is 'W00' for NEWICD, then PROB1 will be 'W00' and if not PROB1 will be 'NO'). My code is:&lt;/P&gt;
&lt;P&gt;DATA INJLIB.NT;&lt;BR /&gt;IF NEWICD ='W00' THEN PROB1='W00';&lt;BR /&gt;ELSE IF NEWICD NE 'W00' THEN PROB1 ='NO';&lt;BR /&gt;SET INJLIB.NT;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;However, these are the first ten lines of the output data:&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="Angmar_0-1613584757942.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54858i81C4FAC1ADD5AF24/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Angmar_0-1613584757942.png" alt="Angmar_0-1613584757942.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Why is this happening?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 18:06:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-misidentifying-variable-responses-no-trailing-or-leading/m-p/719987#M222988</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-02-17T18:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAS misidentifying variable responses - no trailing or leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-misidentifying-variable-responses-no-trailing-or-leading/m-p/719988#M222989</link>
      <description>&lt;P&gt;The only obvious problem is the location of the SET statement. It should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA INJLIB.NT;
SET INJLIB.NT;
IF NEWICD ='W00' THEN PROB1='W00';
ELSE IF NEWICD NE 'W00' THEN PROB1 ='NO';
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that's not it, then please provide a portion of your original data following &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;, and not via any other method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, code which overwrites the original data set by creating a new data set with the exact same name as the original data set isn't a good idea, and in rare cases could cause problems like you are seeing.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Feb 2021 18:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-misidentifying-variable-responses-no-trailing-or-leading/m-p/719988#M222989</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-17T18:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS misidentifying variable responses - no trailing or leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-misidentifying-variable-responses-no-trailing-or-leading/m-p/719989#M222990</link>
      <description>&lt;P&gt;You have your statements out of order.&amp;nbsp; The SET statement is an executable statement, not a declarative statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are calculating PROB1 before reading in the current value of NEWCID so the calculations are being done on the previous value of NEWCID.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA INJLIB.NT;
  SET INJLIB.NT;
  IF NEWICD ='W00' THEN PROB1='W00';
  ELSE IF NEWICD NE 'W00' THEN PROB1 ='NO';
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Feb 2021 18:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-misidentifying-variable-responses-no-trailing-or-leading/m-p/719989#M222990</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-17T18:06:41Z</dc:date>
    </item>
  </channel>
</rss>

