<?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: How to use 'Select' Statement to make a new variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-Select-Statement-to-make-a-new-variable/m-p/720756#M27732</link>
    <description>&lt;P&gt;Your code needs a &lt;FONT face="courier new,courier"&gt;cards;&lt;/FONT&gt; statement after the &lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt; and before the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your syntax is wrong in select, it should be (here is one example, you can change the rest of them):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;when (CourseGrade ge 93 and CourseGrade le 97) FGrade = 'A';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, your select statements will assign a 93 to A-, even though you appear to have it in the A category, because your conditions in the select statement overlap, and you probably want to fix that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your future benefit, when you get errors in the log, &lt;STRONG&gt;SHOW US THE LOG&lt;/STRONG&gt;. Show us the entire log of the step where the errors are, in the sequence it appears in the log, with nothing chopped out.&lt;/P&gt;</description>
    <pubDate>Sun, 21 Feb 2021 18:12:27 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-02-21T18:12:27Z</dc:date>
    <item>
      <title>How to use 'Select' Statement to make a new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-Select-Statement-to-make-a-new-variable/m-p/720746#M27731</link>
      <description>&lt;P&gt;I am having trouble figuring out how to use select here. I want to use the select statement to make a new variable called 'FGrade', but I am not sure what I can do or what I cannot do with a select statement. It keeps giving me multiple errors, but I am not sure how to fix it. I would appreciate any help. Here is my code so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data school;
input Age Quiz : $1. Midterm Final;
if Age eq 12 then Grade = 6;
	else if Age eq 13 then Grade = 8;
if Quiz eq 'A' then QuizGrade=95;
else if Quiz eq 'B' then QuizGrade=85;
else if Quiz eq 'C' then QuizGrade=75;
else if Quiz eq 'D' then QuizGrade=70;
else if Quiz eq 'F' then QuizGrade=65;
CourseGrade = (0.2*QuizGrade)+(0.3*Midterm)+(0.5*Final);
*Part c. - Using SELECT statements;
select;
when (CourseGrade ge 97) FGrade = 'A+';
when (CourseGrade ge 93 and le 97) FGrade = 'A';
when (CourseGrade ge 90 and le 93) FGrade = 'A-';
when (CourseGrade ge 87 and le 90) FGrade = 'B+';
when (CourseGrade ge 83 and le 87) FGrade = 'B';
when (CourseGrade ge 80 and le 83) FGrade = 'B';
when (CourseGrade ge 77 and le 80) FGrade = 'C+';
when (CourseGrade ge 73 and le 77) FGrade = 'C';
when (CourseGrade ge 70 and le 73) FGrade = 'C-';
when (CourseGrade ge 67 and le 70) FGrade = 'D+';
when (CourseGrade ge 63 and le 67) FGrade = 'D';
when (CourseGrade ge 60 and le 63) FGrade = 'D-';
when (CourseGrade lt 60) FGrade = 'F';
otherwise;
end;
12 A 92 95
12 B 88 88
13 C 78 75
13 A 92 93
12 F 55 50
13 B 88 82
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 21 Feb 2021 17:00:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-Select-Statement-to-make-a-new-variable/m-p/720746#M27731</guid>
      <dc:creator>Abby1</dc:creator>
      <dc:date>2021-02-21T17:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 'Select' Statement to make a new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-Select-Statement-to-make-a-new-variable/m-p/720756#M27732</link>
      <description>&lt;P&gt;Your code needs a &lt;FONT face="courier new,courier"&gt;cards;&lt;/FONT&gt; statement after the &lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt; and before the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your syntax is wrong in select, it should be (here is one example, you can change the rest of them):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;when (CourseGrade ge 93 and CourseGrade le 97) FGrade = 'A';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, your select statements will assign a 93 to A-, even though you appear to have it in the A category, because your conditions in the select statement overlap, and you probably want to fix that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For your future benefit, when you get errors in the log, &lt;STRONG&gt;SHOW US THE LOG&lt;/STRONG&gt;. Show us the entire log of the step where the errors are, in the sequence it appears in the log, with nothing chopped out.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2021 18:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-Select-Statement-to-make-a-new-variable/m-p/720756#M27732</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-21T18:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use 'Select' Statement to make a new variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-use-Select-Statement-to-make-a-new-variable/m-p/720758#M27733</link>
      <description>&lt;P&gt;You have no DATALINES statement.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Feb 2021 18:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-use-Select-Statement-to-make-a-new-variable/m-p/720758#M27733</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-02-21T18:14:28Z</dc:date>
    </item>
  </channel>
</rss>

