<?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 creating new variables in if-then statements in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388562#M93188</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data employees;
infile 'c:\users\************\*******\employees.dat';
input ssn :$1-11 name &amp;amp; $12-28 dob :date10. paygrade $ monsal :comma6.2 job &amp;amp; :$71-100;
if paygrade = 'gr20' then do;
minimum = 50000.00;
maximum = 70000.00;
end;

age = int(yrdif(dob, today (), 'age'));
put monsal dollar7.2;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am trying to create min and max variables based on the paygrade codes. This is an exercise that comes out of the "The Little SAS Book." When I run this program I get two new variables for minimum and maximum but there are just periods in the columns. I tried using 50000 instead of 50000.00 and that didn't work either. Do I have a formatting problem with the numeric data or is my program not written correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is exercise 31d from Chapter 3 in "Exercises and Projects for The Little SAS Book."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Aug 2017 18:36:52 GMT</pubDate>
    <dc:creator>andrewfau</dc:creator>
    <dc:date>2017-08-16T18:36:52Z</dc:date>
    <item>
      <title>creating new variables in if-then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388562#M93188</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data employees;
infile 'c:\users\************\*******\employees.dat';
input ssn :$1-11 name &amp;amp; $12-28 dob :date10. paygrade $ monsal :comma6.2 job &amp;amp; :$71-100;
if paygrade = 'gr20' then do;
minimum = 50000.00;
maximum = 70000.00;
end;

age = int(yrdif(dob, today (), 'age'));
put monsal dollar7.2;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I am trying to create min and max variables based on the paygrade codes. This is an exercise that comes out of the "The Little SAS Book." When I run this program I get two new variables for minimum and maximum but there are just periods in the columns. I tried using 50000 instead of 50000.00 and that didn't work either. Do I have a formatting problem with the numeric data or is my program not written correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is exercise 31d from Chapter 3 in "Exercises and Projects for The Little SAS Book."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 18:36:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388562#M93188</guid>
      <dc:creator>andrewfau</dc:creator>
      <dc:date>2017-08-16T18:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variables in if-then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388567#M93189</link>
      <description>&lt;P&gt;You get the periods because at no time in your data do you have paygrade='gr20'. I don't know if this is just a capitalization mismatch, or that 'gr20' never appears in your data. You need to write code to tell SAS what it should do if it finds paygrade is not equal to 'gr20'.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 18:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388567#M93189</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-08-16T18:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variables in if-then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388571#M93190</link>
      <description>Things total check in the data-file: is there any obs having paygrade "gr20"? Both letters have time be in low case.&lt;BR /&gt;Maximum and minimum are only set of paygrade is gr20, any obs having another value will show missing value fit both vars.</description>
      <pubDate>Wed, 16 Aug 2017 18:49:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388571#M93190</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2017-08-16T18:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variables in if-then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388572#M93191</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14522i4E1EF35E9B98CB03/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.jpg" alt="Untitled.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 18:50:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388572#M93191</guid>
      <dc:creator>andrewfau</dc:creator>
      <dc:date>2017-08-16T18:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variables in if-then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388573#M93192</link>
      <description>Gotcha. It was the lowercase that was the problem. Thanks!</description>
      <pubDate>Wed, 16 Aug 2017 18:51:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388573#M93192</guid>
      <dc:creator>andrewfau</dc:creator>
      <dc:date>2017-08-16T18:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variables in if-then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388576#M93193</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data employees;

input ssn :$1-11 name &amp;amp; $12-28 dob :date10. paygrade $ monsal :comma6.2 job &amp;amp; :$71-100;
if paygrade = 'GR20' then do;
minimum = 50000;
maximum = 70000;
end;
if paygrade = 'GR21' then do;
minimum = 55000;
maximum = 75000;
end;
if paygrade = 'GR22' then do;
minimum = 60000;
maximum = 85000;
end;
if paygrade = 'GR23' then do;
minimum = 70000;
maximum = 100000;
end;
if paygrade = 'GR24' then do;
minimum = 80000;
maximum = 120000;
end;
if paygrade = 'GR25' then do;
minimum = 100000;
maximum = 150000;
end;
if paygrade = 'GR26' then do;
minimum = 120000;
maximum = 200000;
end;
age = int(yrdif(dob, today (), 'age'));
put monsal dollar7.2;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a way i can condense those if then statements or do I need to write them all individually for a problem like this?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 18:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388576#M93193</guid>
      <dc:creator>andrewfau</dc:creator>
      <dc:date>2017-08-16T18:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: creating new variables in if-then statements</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388583#M93195</link>
      <description>&lt;P&gt;You could probably do an array. Not sure it's less code in the end, but easier to manage perhaps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array min_pay(20:26) (50000 55000 60000 70000 ... 120000);
array max_pay(20:26) (70000 75000 .. 200000);

grade = input(compress(paygrade, ,'kd'), 8.);
minimum = min_pay(grade);
maximum = max_pay(grade);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Aug 2017 19:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-new-variables-in-if-then-statements/m-p/388583#M93195</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-16T19:21:57Z</dc:date>
    </item>
  </channel>
</rss>

