<?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: Missing values issue in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Missing-values-issue/m-p/704269#M26116</link>
    <description>&lt;P&gt;Try this one:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA work.import;
  SET work.import;

  select;
    when ( (AGE &amp;gt;=0 ) AND (AGE&amp;lt;=9 ) ) do; NAGE= "0-9 YEARS";   groupage=1; end;
    when ( (AGE &amp;gt;=10) AND (AGE&amp;lt;=17) ) do; NAGE= "10-17 YEARS"; groupage=2; end;
    when ( (AGE &amp;gt;=18) AND (AGE&amp;lt;=35) ) do; NAGE= "18-35 YEARS"; groupage=3; end;
    when ( (AGE &amp;gt;=36) AND (AGE&amp;lt;=50) ) do; NAGE= "36-50 YEARS"; groupage=4; end;
    when ( (AGE &amp;gt;=51) AND (AGE&amp;lt;=64) ) do; NAGE= "51-64 YEARS"; groupage=5; end;
    when ( (AGE &amp;gt;=65)               ) do; NAGE= "65+";         groupage=6; end;
    otherwise put "ERROR: value!";
  end;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One more side note: if I were you I would use not:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;(AGE &amp;gt;=0 ) AND (AGE&amp;lt;=9 )&lt;/LI-CODE&gt;
&lt;P&gt;but rather:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(AGE &amp;gt;=0 ) AND (AGE &amp;lt; 10)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Mon, 07 Dec 2020 20:06:15 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2020-12-07T20:06:15Z</dc:date>
    <item>
      <title>Missing values issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Missing-values-issue/m-p/704257#M26114</link>
      <description>&lt;P&gt;I have a data set where i grouped the age groups and then i wanted to assign a number to each group but when i run the code some of them work but then some groups don't show any numbers. Only 0-9 and 65+ works the rest of them are blank&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA work.import;&lt;BR /&gt;SET work.import;&lt;BR /&gt;IF (AGE &amp;gt;=0) AND (AGE&amp;lt;=9) THEN NAGE= "0-9 YEARS";&lt;BR /&gt;IF (AGE &amp;gt;=10) AND (AGE&amp;lt;=17) THEN NAGE= "10-17 YEARS";&lt;BR /&gt;IF (AGE &amp;gt;=18) AND (AGE&amp;lt;=35) THEN NAGE= "18-35 YEARS";&lt;BR /&gt;IF (AGE &amp;gt;=36) AND (AGE&amp;lt;=50) THEN NAGE= "36-50 YEARS";&lt;BR /&gt;IF (AGE &amp;gt;=51) AND (AGE&amp;lt;=64) THEN NAGE= "51-64 YEARS";&lt;BR /&gt;IF (AGE &amp;gt;=65) THEN NAGE= "65+";&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;data work.import;&lt;BR /&gt;set work.import;&lt;BR /&gt;if NAGE =  "0-9 YEARS" THEN groupage=1;&lt;BR /&gt;if NAGE = "10-17 YEARS" THEN groupage=2;&lt;BR /&gt;if NAGE = "18-35 YEARS" THEN groupage=3;&lt;BR /&gt;if NAGE = "36-50 YEARS" THEN groupage=4;&lt;BR /&gt;if NAGE = "51-64 YEARS" THEN groupage=6;&lt;BR /&gt;if NAGE = "65+" THEN groupage=7;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Dec 2020 19:30:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Missing-values-issue/m-p/704257#M26114</guid>
      <dc:creator>Daisy808</dc:creator>
      <dc:date>2020-12-07T19:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: Missing values issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Missing-values-issue/m-p/704269#M26116</link>
      <description>&lt;P&gt;Try this one:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA work.import;
  SET work.import;

  select;
    when ( (AGE &amp;gt;=0 ) AND (AGE&amp;lt;=9 ) ) do; NAGE= "0-9 YEARS";   groupage=1; end;
    when ( (AGE &amp;gt;=10) AND (AGE&amp;lt;=17) ) do; NAGE= "10-17 YEARS"; groupage=2; end;
    when ( (AGE &amp;gt;=18) AND (AGE&amp;lt;=35) ) do; NAGE= "18-35 YEARS"; groupage=3; end;
    when ( (AGE &amp;gt;=36) AND (AGE&amp;lt;=50) ) do; NAGE= "36-50 YEARS"; groupage=4; end;
    when ( (AGE &amp;gt;=51) AND (AGE&amp;lt;=64) ) do; NAGE= "51-64 YEARS"; groupage=5; end;
    when ( (AGE &amp;gt;=65)               ) do; NAGE= "65+";         groupage=6; end;
    otherwise put "ERROR: value!";
  end;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One more side note: if I were you I would use not:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;(AGE &amp;gt;=0 ) AND (AGE&amp;lt;=9 )&lt;/LI-CODE&gt;
&lt;P&gt;but rather:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(AGE &amp;gt;=0 ) AND (AGE &amp;lt; 10)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 20:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Missing-values-issue/m-p/704269#M26116</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-12-07T20:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Missing values issue</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Missing-values-issue/m-p/704301#M26119</link>
      <description>&lt;P&gt;The reason you only get correct values for last group is because when you use multiple IF statements with the same variable then the result from the LAST one is kept. With IF statements you would use ELSE so that when the previous test was false it go to the next one.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;DATA work.import;
SET work.import;
     IF (AGE &amp;gt;=0) AND (AGE&amp;lt;=9) THEN NAGE= "0-9 YEARS";
Else IF (AGE &amp;gt;=10) AND (AGE&amp;lt;=17) THEN NAGE= "10-17 YEARS";
Else IF (AGE &amp;gt;=18) AND (AGE&amp;lt;=35) THEN NAGE= "18-35 YEARS";
Else IF (AGE &amp;gt;=36) AND (AGE&amp;lt;=50) THEN NAGE= "36-50 YEARS";
Else IF (AGE &amp;gt;=51) AND (AGE&amp;lt;=64) THEN NAGE= "51-64 YEARS";
Else IF (AGE &amp;gt;=65) THEN NAGE= "65+";
RUN;&lt;/PRE&gt;
&lt;P&gt;And again, using&lt;/P&gt;
&lt;PRE&gt;Data work.import;
   set work.import.&lt;/PRE&gt;
&lt;P&gt;Is just asking for problems as this replaces the source data set every time you use the same data set.&lt;/P&gt;
&lt;P&gt;All you need is one typo like&lt;/P&gt;
&lt;PRE&gt;IF Age &amp;gt; 65;&lt;/PRE&gt;
&lt;P&gt;to lose a lot of data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 22:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Missing-values-issue/m-p/704301#M26119</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-12-07T22:04:27Z</dc:date>
    </item>
  </channel>
</rss>

