<?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 Homework Assignment Help no errors but want to make sure MIN and MAX variables entered corre in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532346#M145866</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/29388"&gt;@philjones820&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data baseball4;
set work.baseball;
array NumVar _numeric_;
do over NumVar;
if NumVar=. then NumVar=0;
end;
format AVG 6.3;
format SLG 6.3;
MIN=SALARY&amp;lt; 500000;
MAX=SALARY&amp;lt;=10000000;
OBP=H+HBP/PA;
format OBP 6.3;
ISO=SLG-AVG;
format ISO 6.3;
SP=SO/PA;
format SP percent7.1;
BA=H/AB;
format BA 6.3;
IF SALARY &amp;gt;=MAX THEN Salary_Description='Filthy Rich';
ELSE Salary_Description='none';
if SALARY &amp;lt; MIN then sal_type ='Less than League Minimum';
/* ELSE if SALARY &amp;gt;= MIN then sal_type='Filthy Rich'; */
ELSE sal_type='middle';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi, I'm not getting any errors in my code, but can someone look at the attached assignment and let me know if there is a better or more efficient way to write this according to the assignment criteria. Thanks, much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Don’t you need to calculate the min/max?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 03 Feb 2019 05:41:09 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-02-03T05:41:09Z</dc:date>
    <item>
      <title>SAS Homework Assignment Help no errors but want to make sure MIN and MAX variables entered correctly</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532333#M145862</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data baseball4;
set work.baseball;
array NumVar _numeric_;
do over NumVar;
if NumVar=. then NumVar=0;
end;
format AVG 6.3;
format SLG 6.3;
MIN=SALARY&amp;lt; 500000;
MAX=SALARY&amp;lt;=10000000;
OBP=H+HBP/PA;
format OBP 6.3;
ISO=SLG-AVG;
format ISO 6.3;
SP=SO/PA;
format SP percent7.1;
BA=H/AB;
format BA 6.3;
IF SALARY &amp;gt;=MAX THEN Salary_Description='Filthy Rich';
ELSE Salary_Description='none';
if SALARY &amp;lt; MIN then sal_type ='Less than League Minimum';
/* ELSE if SALARY &amp;gt;= MIN then sal_type='Filthy Rich'; */
ELSE sal_type='middle';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi, I'm not getting any errors in my code, but can someone look at the attached assignment and let me know if there is a better or more efficient way to write this according to the assignment criteria. Thanks, much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Feb 2019 00:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532333#M145862</guid>
      <dc:creator>philjones820</dc:creator>
      <dc:date>2019-02-03T00:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Homework Assignment Help no errors but want to make sure MIN and MAX variables entered corre</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532335#M145863</link>
      <description>&lt;P&gt;What about:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* half a million or less */
min= (salary &amp;lt;= 500000);
/* at least 10 million */
max= (salary &amp;gt;= 10000000);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now the way you've coded the variables MIN and MAX will have the values 1 or 0. You basically have right from the first equal sign a logical comparison which either returns True or False (which gives you the values 1 or 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now have a look what you've done here:&lt;/P&gt;
&lt;PRE&gt;IF SALARY &amp;gt;=MAX THEN Salary_Description='Filthy Rich';&lt;/PRE&gt;
&lt;P&gt;That will give you a wrong result. It should be:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;IF MAX THEN Salary_Description='Filthy Rich';
or alternatively:
IF MAX=1 THEN Salary_Description='Filthy Rich';&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also:&lt;/P&gt;
&lt;P&gt;When you have a statement like below...&lt;/P&gt;
&lt;PRE&gt;IF SALARY &amp;gt;=MAX THEN Salary_Description='Filthy Rich';&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;...using a variable which hasn't been defined before then be aware that SAS will assign this variable the length of the string you're assigning. What this means: If you then later on in your code have another such assignment where you try to assign a longer string then this string will get truncated. To avoid this: Always define the length of new variables explicitly before you use it using a length statement.&lt;/P&gt;
&lt;PRE&gt;length Salary_Description $40;
Salary_Description='Filthy Rich'&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And last but not least and not what you're asked to do in your assignment but something I guess this assignment is meant to achieve as a learning experience to prepare you for the next lesson: An efficient way for recoding or grouping which avoids creating all these additional variables is using SAS Formats and Informats.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  value salaryRangeDesc
    low - 500000 = 'Less than League Minimum'
    10000000 - high = 'Filthy Rich'
    other = 'None'
    ;
quit;

data sample;
  do salary= .,0,499999,500000,500001,09999999,10000000,10000001;
    Salary_Description=put(salary,salaryRangeDesc.);
    output;
  end;
  stop;
run;
proc print data=sample;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Feb 2019 06:15:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532335#M145863</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-02-03T06:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Homework Assignment Help no errors but want to make sure MIN and MAX variables entered corre</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532346#M145866</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/29388"&gt;@philjones820&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data baseball4;
set work.baseball;
array NumVar _numeric_;
do over NumVar;
if NumVar=. then NumVar=0;
end;
format AVG 6.3;
format SLG 6.3;
MIN=SALARY&amp;lt; 500000;
MAX=SALARY&amp;lt;=10000000;
OBP=H+HBP/PA;
format OBP 6.3;
ISO=SLG-AVG;
format ISO 6.3;
SP=SO/PA;
format SP percent7.1;
BA=H/AB;
format BA 6.3;
IF SALARY &amp;gt;=MAX THEN Salary_Description='Filthy Rich';
ELSE Salary_Description='none';
if SALARY &amp;lt; MIN then sal_type ='Less than League Minimum';
/* ELSE if SALARY &amp;gt;= MIN then sal_type='Filthy Rich'; */
ELSE sal_type='middle';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hi, I'm not getting any errors in my code, but can someone look at the attached assignment and let me know if there is a better or more efficient way to write this according to the assignment criteria. Thanks, much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Don’t you need to calculate the min/max?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Feb 2019 05:41:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532346#M145866</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-03T05:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Homework Assignment Help no errors but want to make sure MIN and MAX variables entered corre</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532428#M145889</link>
      <description>Thanks very much, I will try that!&lt;BR /&gt;</description>
      <pubDate>Sun, 03 Feb 2019 16:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532428#M145889</guid>
      <dc:creator>philjones820</dc:creator>
      <dc:date>2019-02-03T16:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Homework Assignment Help no errors but want to make sure MIN and MAX variables entered corre</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532823#M146034</link>
      <description>Quick question-Is there a way to hide the variables MIN and MAX so that they wont show in the output results?</description>
      <pubDate>Tue, 05 Feb 2019 01:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/532823#M146034</guid>
      <dc:creator>philjones820</dc:creator>
      <dc:date>2019-02-05T01:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Homework Assignment Help no errors but want to make sure MIN and MAX variables entered corre</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/533073#M146115</link>
      <description>drop min max;&lt;BR /&gt;&lt;BR /&gt;Add a drop statement in your last step and it will drop the variables at the end of the step.</description>
      <pubDate>Tue, 05 Feb 2019 20:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Homework-Assignment-Help-no-errors-but-want-to-make-sure-MIN/m-p/533073#M146115</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-02-05T20:34:29Z</dc:date>
    </item>
  </channel>
</rss>

