<?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: Code not running as supposed to in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/804599#M33426</link>
    <description>&lt;P&gt;Thank you! It solved the problem.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Mar 2022 18:44:37 GMT</pubDate>
    <dc:creator>GingerJJ</dc:creator>
    <dc:date>2022-03-28T18:44:37Z</dc:date>
    <item>
      <title>Code not running as supposed to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/803708#M33352</link>
      <description>&lt;P&gt;I have the following code:&lt;/P&gt;
&lt;P&gt;Data SSN1;&lt;/P&gt;
&lt;P&gt;set ssn;&lt;BR /&gt;if lastfour_ssn = 0 then SSN = 1;&lt;BR /&gt;if lastfour_ssn = 9999 then ssn= 2;&lt;BR /&gt;if lastfour_ssn &amp;gt;9999 or lastfour_ssn&amp;lt;1000 then ssn=3;&lt;BR /&gt;if lastfour_ssn= . then ssn= 4;&lt;BR /&gt;else ssn=5;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My data has a bunch of three-digit numbers, or 0 value, but in the new dataset, ssn only has value of 4 or 5.&lt;/P&gt;
&lt;P&gt;Where did I do wrong?&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 21:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/803708#M33352</guid>
      <dc:creator>GingerJJ</dc:creator>
      <dc:date>2022-03-23T21:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Code not running as supposed to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/803709#M33353</link>
      <description>&lt;P&gt;Without having any actual value it is likely because you are reassigning values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;Data SSN1;
   set ssn;
   if lastfour_ssn = 0 then SSN = 1;
   else if lastfour_ssn = 9999 then ssn= 2;
   else if lastfour_ssn &amp;gt;9999 or (0&amp;lt; lastfour_ssn&amp;lt;1000) then ssn=3;
   else if lastfour_ssn= . then ssn= 4;
   else ssn=5;
run;&lt;/PRE&gt;
&lt;P&gt;You code when it got to the comparison for missing and they weren't went to assign every thing to 5.&lt;/P&gt;
&lt;P&gt;If the 1, 2, or 3 codes are assigned you do not want to check if it the value is missing.&lt;/P&gt;
&lt;P&gt;Edited the SSN=3.&amp;nbsp;&amp;nbsp; MISSING is less than anything so without a restriction you would never get the 4 result.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 14:20:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/803709#M33353</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-24T14:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: Code not running as supposed to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/803721#M33354</link>
      <description>&lt;P&gt;Since LASTFOUR_SSN is either missing or it isn't any value assigned to SSN by the first three IF statement is overwritten. So you essentially ran this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data SSN1;
  set ssn;
  if lastfour_ssn= . then ssn= 4;
  else ssn=5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Add more ELSE keywords so that only one of the five assignment statements will run for any given observation.&lt;/P&gt;
&lt;P&gt;Follow this pattern:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ... then ...;
else if ... then ... ;
else if ... then ...;
else ...;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Mar 2022 23:42:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/803721#M33354</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-23T23:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: Code not running as supposed to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/803783#M33358</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393829"&gt;@GingerJJ&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You have a contradiction in your logic. &lt;STRONG&gt;if&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;lastfour_ssn&amp;lt;1000 then ssn=3&lt;/STRONG&gt;. and zero is less than 1000.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The appropriate approach would be to use suggestion from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp; with&amp;nbsp; appropriate modifications to your logic.&lt;BR /&gt;Needless to say that last four digits of ssn will always be four characters (0000-9999) or numeric values between 0 and 9999 and there is hardly any scope for greater than 9999.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 12:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/803783#M33358</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-03-24T12:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Code not running as supposed to</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/804599#M33426</link>
      <description>&lt;P&gt;Thank you! It solved the problem.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 18:44:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Code-not-running-as-supposed-to/m-p/804599#M33426</guid>
      <dc:creator>GingerJJ</dc:creator>
      <dc:date>2022-03-28T18:44:37Z</dc:date>
    </item>
  </channel>
</rss>

